accessing parsed JSON on the iPhone SDK

Posted by itai alter on Stack Overflow See other posts from Stack Overflow or by itai alter
Published on 2010-04-25T08:52:22Z Indexed on 2010/04/25 9:03 UTC
Read the original article Hit count: 308

Filed under:
|
|
|

Hello All! I've been following the great tutorial about (iPhone, json and Flickr API and I did manage to access the parsed json info just fine.

Now I'm trying to do the same thing with the Twitter API, and I am able to get the json info and parse it, but I can't seem to access it like in Flickr.

I noticed that the json info that is retrieved from Twitter is a little different from Flickr.

The Flickr json info starts straight with a curly braces ({), while the Twitter json info starts with a square bracket and then a curly braces ([{). I understand that it means it's an array inside the json info, but I don't know how to access it.

In the Flickr example, I access the objects like so (the second line takes the number of pages Flickr has reported):

NSDictionary *results = [jsonString JSONValue];
pagesString = [[results objectForKey:@"photos"] objectForKey:@"pages"];

but I can't seem to access the Twitter response in the same way...

Does anyone know of a solution?

(here's an example of the Twitter JSON response: api.twitter.com/1/statuses/public_timeline.json )

Thanks a bunch!

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about JSON