Both Cocoa and iOS have built-in methods to parse (and generate) JSON data using NSJSONSerialization.
Most commonly you’ll want to call a URL with parameters which will return some data. You take this output and tell Objective-C that it’s JSON, then typecast the return to an array or a dictionary which in turn lets you access the data. It’s genius!
Here’s an example:This content is for members only.
Once you have access to the top level elements you can then loop through each one, examining what’s in it and access what you need.
- More details about the JSON Format: http://www.json.org/
- NSJSONSerialization Class Reference: http://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSJSONSerialization_Class/Reference/Reference.html
- JSONKit Framework: https://github.com/johnezang/JSONKit