how to use JSON in your app. (click the images to enlarge)
2.) Open the dmg, and drag the JSON folder into your project in Xcode. Check “Copy items into destination group’s folder (if needed)” when prompted.
3.) Once the source is embedded into your project, you need to import the framework to use it in your code
#import "JSON.h"
4.) Create a SBJSON object to parse JSON into a native Cocoa object. SBJSON will return either a NSDictionary or NSArray depending on the structure of the data. You should know ahead of time the structure of the JSON object your parsing and whether it’s a single JSON object or an array of JSON objects and use the appropriate Cocoa class.
SBJSON *parser = [[SBJSON alloc] init];
NSDictionary *object = [parser objectWithString:json_string error:nil];
Here’s an example showing how to download the public timeline from Twitter as JSON and parse it.
SBJSON *parser = [[SBJSON alloc] init];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://twitter.com/statuses/public_timeline.json"]];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
NSArray *statuses = [parser objectWithString:json_string error:nil];
for (NSDictionary *status in statuses)
{
NSLog(@"%@ - %@", [status objectForKey:@"text"], [[status objectForKey:@"user"] objectForKey:@"screen_name"]);
}