Deserialize JSON To Objective-C Objects – iOS And JSON Part 2

In Part 1 of the series Serialize Objective-C Objects to JSON I wrote a few examples for serializing objects into JSON. Specifically, a dictionary with several key/value pairs as well as an array. In this post I will show the opposite, how to deserialize JSON to Objective-C objects.

It’s important to note that the examples in both of these posts use the NSJSONSerialization class that Apple released beginning with iOS 5. For basic JSON serializing and deserializing no external library is required.

To keep the code focused on the task at hand, rather than include a bunch of networking code to acquire JSON, I will simulate the process and simply read JSON from a file that I’ve added to my project. The file contents are extracted from a Twitter API example that lists JSON for a sample search:

Continue reading