SBJson不会深入NSDictionary

时间:2012-08-31 01:29:37

标签: iphone xcode json nsdictionary sbjson

由于这个原因,我一整天都在墙上敲我的头。

我正在尝试解析此JSON blob here

这就是我正在使用的:

NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];

NSDictionary *results = [responseString JSONValue];

NSArray *allTweets = [[results objectForKey:@"response"] objectForKey:@"posts"];

然而,当我尝试这样做时:

NSURL *url = [NSURL URLWithString:[[[[aTweet objectForKey:@"posts"] objectForKey:@"photos"] objectForKey:@"original_size"] objectForKey:@"url"]];

它没有给我任何错误,但* url设置为“null”。

我已经将CFShow用于NSDictionary,但“photos”键之后的所有内容都是常规字符串,而不是JSON格式。

谁能告诉我为什么?

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

试试这个。

    for (int i = 0; i < [[[results objectForKey:@"response"] objectForKey:@"posts"] count]; i++) {
        NSLog(@"url data = %@",[[[[[[[results objectForKey:@"response"]
        objectForKey:@"posts"] objectAtIndex:i] objectForKey:@"photos"]
        objectAtIndex:0] objectForKey:@"original_size"] objectForKey:@"url"]);
    }