I have an application using basic data with 3 objects with very similar attributes. The relationship is:
Industry โ> Menu โ> Category โ> FoodItem
Each object has an associated class: example

I am trying to create a JSON representation of data in a sqlite database.
//gets a single menu record which has some categories and each of these have some food items id obj = [NSArray arrayWithObject:[[DataStore singleton] getHomeMenu]]; NSError *err; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:obj options:NSJSONWritingPrettyPrinted error:&err]; NSLog(@"JSON = %@", [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]);
But instead of JSON, I get a SIGABRT error.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (Menu)'
Any ideas how to fix this or how to make entity classes (Branch, Menu, etc.) compatible with JSON serialization?
json objective-c serialization iphone ios5
Vaibhav Garg Mar 27 '12 at 15:58 2012-03-27 15:58
source share