Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I parse this Flickr response?

I get this from a sample Flickr response in their api site:

jsonFlickrApi({"method":{"_content":"flickr.test.echo"}, "format":{"_content":"json"}, "api_key":{"_content":"8038f7f7d7151ccbf6df2aa10b1b35ae"}, "stat":"ok"})

I can see the dictionary in there, right after the words jsonFlickApi. But how do I get rid of that leading text and put the dictionary into my NSDictionary?

like image 503
marciokoko Avatar asked Apr 10 '13 16:04

marciokoko


1 Answers

Use the NSJSONSerialization class to parse the JSON data.

Edit: The jsonFlickrApi(...) indicates that you're using a JSONP endpoint to talk to Flickr. You don't need this; a plain JSON endpoint is fine. According to this Flickr API documentation you can fix this by including the parameter nojsoncallback with the value 1 when you make your request.

like image 183
bdesham Avatar answered Oct 19 '22 19:10

bdesham