How do I parse this Flickr response?
Asked Answered
T

1

8

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?

Talamantes answered 10/4, 2013 at 16:5 Comment(0)
H
18

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.

Heckman answered 10/4, 2013 at 16:8 Comment(1)
but will that get rid of the leading string?Talamantes

© 2022 - 2024 — McMap. All rights reserved.