解析Tumblr的回调响应

时间:2014-01-19 17:13:54

标签: objective-c json callback response tumblr

如何解析tumblr响应以检索诸如照片链接,标题等项目。根据Tumblr API,它是JSON格式,但我似乎无法理解如何编码它。这是回复的片段:

{ 
    "blog_name" = myBlogName;
    "can_reply" = 0;
    caption = "<p>pending again</p>";
    date = "2014-01-19 15:54:22 GMT";
    followed = 0;
    format = html;
    highlighted = ();
    id = 73836876344;
    "image_permalink" = "http://bantaybayan.tumblr.com/image/73836876344";
    liked = 0;
    "note_count" = 0;
    photos =         (
                    {
            "alt_sizes" =                 (
                                    {
                    height = 558;
                    url = "http://24.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_1280.jpg";
                    width = 740;
                },
                                    {
                    height = 377;
                    url = "http://31.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_500.jpg";
                    width = 500;
                },
                                    {
                    height = 302;
                    url = "http://24.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_400.jpg";
                    width = 400;
                },
                                    {
                    height = 189;
                    url = "http://25.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_250.jpg";
                    width = 250;
                },
                                    {
                    height = 75;
                    url = "http://31.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_100.jpg";
                    width = 100;
                },
                                    {
                    height = 75;
                    url = "http://31.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_75sq.jpg";
                    width = 75;
                }
            );
            caption = "";
            "original_size" =                 {
                height = 558;
                url = "http://24.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_1280.jpg";
                width = 740;
            };
        }
    );
    "post_url" = "http://bantaybayan.tumblr.com/post/73836876344/pending-again";
    "reblog_key" = LUOtTeAe;
    "short_url" = "http://tmblr.co/Z89Zxo14n1L8u";
    slug = "pending-again";
    state = published;
    tags =         (
    );
    timestamp = 1390146862;
    type = photo;
}

提前致谢

1 个答案:

答案 0 :(得分:0)

首先,这看起来不像JSON。使用JSONLint

等验证程序进行检查

如果您使用JSON数据的编辑器,则会更容易。有很多免费的在线服务http://jsoneditoronline.org/

对于Objective-C,这个SO问题可能会帮助你:Parsing JSON using Objective-C