How to parsing JSON object in iPhone SDK (XCode) using JSON-Framework

Assuming you’ve followed the instructions to install JSON-Framework into your project, here’s how you use it (taken from the docs here) :

// Parse the string into JSON
NSDictionary *json = [myString JSONValue];

// Get the objects you want, e.g. output the second item's client id
NSArray *items = [json valueForKeyPath:@"data.array"];
NSLog(@" client Id : %@", [[items objectAtIndex:1] objectForKey:@"clientId"]);

Leave a Comment