访问JSON响应中的密钥

时间:2012-07-18 16:34:10

标签: objective-c json ios5 asihttprequest

如何在以下JSON响应中检查 uids 是否为nil?

{
height = 480;
pid = "F@dd705e6b96a6e894556c0db84870501e_d97383cc80238c38b8907d99690fa1c9";
tags =     (
            {
        attributes =             {
            glasses =                 {
                confidence = 97;
                value = false;
            };
            smiling =                 {
                confidence = 97;
                value = false;
            };
        };
        center =             {
            x = "60.83";
            y = "75.21";
        };
        gid = "<null>";
        height = "49.58";
        label = "";
        manual = 0;
        nose =             {
            x = "76.21";
            y = "77.16";
        };
        pitch = "-5.55";
        recognizable = 0;
        roll = "-0.45";
        uids =             (          // <<<<<========== UIDs Key
        );
        width = "66.11";
        yaw = "-19.56";
    }
);
url = "http://face.com/images/ph/a6e529853432599dad6da996746cb070.jpg";
width = 360;
}

当我尝试:

if ([[[[photo objectForKey:@"tags"] objectAtIndex:0] valueForKey:@"uids"] count] == 0)

它一直在返回FALSE。

我能够成功访问很多这些密钥。但这只是给我一些问题的关键因素。

例如,要访问网址键,我正在使用:

[photo objectForKey:@"url"];

它的工作非常好。

我对 uids 键做错了什么?

0 个答案:

没有答案