iOS - Parsing JSON
Very often we need to access some kind of service available on the internet to gather some data to work with. Most of nowadays services prefer to send data using the JSON format (learn more about json here). It's simple and compared to XML, smaller.
In iOS there is no native way to work with json text, but there are some great library avaliable out there that make the job really easy. One of the best I know is the TouchJSON (a wiki about it is avaliable here). This library makes really simple the task to parse a JSON string.
Continue reading to learn how to use this library.
To install this framework, in your xCode, do the following:
open the "Other Sources" group, and then open the yourappname_Prefix.pch
Add just below the "#import <UIKit/UIKit.h>" the - #import "JSON.h" - line.
This will make the JSON parser available to all of your classes.
This is all you need to install the framework, now to parse a json string just call the method JSONValue on the string you want to translate. Then you will get a NSDictionary or a NSArray object, depending on how your JSON is structured.
You can download the last source for TouchJSON here (read the note below), or a version packed by me (I use this one in my projects) here
Note: in the git repository of Touch i haven't found the source for the TouchJSON framework. So for now, i suggest you download the package i created.














