在objective-c中解析json文件

时间:2012-07-29 15:31:38

标签: iphone objective-c xcode sbjson

我有这个json链接Json_link

我如何获得(17:00)和(Amberg)和(Aubstadt)值。并提前感谢。

1 个答案:

答案 0 :(得分:0)

将JSON库添加到项目中,并将代码放在解析文件

NSArray* latestLoans = [(NSDictionary*)[responseString JSONValue] objectForKey:@"commands"];
[responseString release];

NSLog(@"%@",[[latestLoans objectAtIndex:0] objectForKey:@"name"]);
NSLog(@"%@",[[[latestLoans objectAtIndex:0] objectForKey:@"parameters"] objectForKey:@"container"]);
NSLog(@"%@",[[[latestLoans objectAtIndex:0] objectForKey:@"parameters"] objectForKey:@"content"]);
NSLog(@"%@",[[[latestLoans objectAtIndex:0] objectForKey:@"parameters"] objectForKey:@"position"]);



NSLog(@"%@",[[latestLoans objectAtIndex:1] objectForKey:@"name"]);
NSLog(@"%@",[[[[latestLoans objectAtIndex:1] objectForKey:@"parameters"] objectForKey:@"params"] objectForKey:@"date"]);
NSLog(@"%@",[[[[latestLoans objectAtIndex:1] objectForKey:@"parameters"] objectForKey:@"params"] objectForKey:@"display"]);
NSLog(@"%@",[[[[latestLoans objectAtIndex:1] objectForKey:@"parameters"] objectForKey:@"params"] objectForKey:@"timestamp"]);