How do I parse this Flickr response?

荒凉一梦 提交于 2020-02-01 03:16:46

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/15930932/how-do-i-parse-this-flickr-response

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!