Reputation: 317
How to use JSONKit to deserialize a json string into dictionary? I couldn't find any examples.
Upvotes: 29
Views: 21342
Reputation: 124997
Use the NSString interface that comes with JSONKit. For example:
NSDictionary *deserializedData = [jsonString objectFromJSONString];
You'll either need to know in advance what sort of container you're going to get from the JSON data, or else test the object you get back to figure out its type. (You can use -isKindOfClass: for this.) Most of the time, you already have an expectation of what's in the JSON data, so you know to expect a dictionary or an array, but it's still a good idea to check the class of the object you get back.
Upvotes: 57