如何解析此Flickr响应? [英] How do I parse this Flickr response?

查看:81
本文介绍了如何解析此Flickr响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是从他们的api网站中的示例Flickr响应中得到的:

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"})

在jsonFlickApi一词之后,我可以在其中看到字典.但是我该如何删除该前导文本并将字典放入我的NSDictionary中?

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?

推荐答案

使用

Use the NSJSONSerialization class to parse the JSON data.

jsonFlickrApi(...)表示您正在使用JSONP端点与Flickr对话.您不需要这个;一个普通的JSON端点就可以了.根据此Flickr API文档,您可以通过在值中包含参数nojsoncallback来解决此问题1当您提出请求时.

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.

这篇关于如何解析此Flickr响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆