[转] JsonKit
http://www.14oranges.com/2011/08/how-to-use-jsonkit-for-ios-and-the-rotten-tomatoes-api/
优点, 1 只有2个文件
2 使用简单
//Then import JSONKit.h” in your .m files where ever you need to parse a JSON response import "JSONKit.h" //Whenever you have JSON data that you need to parse (more on how to get some later), you just use the objectFromData method like so NSData* jsonData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err]; NSDictionary *resultsDictionary = [jsonData objectFromJSONData]; Alternatively, if you have your data in string form, you can use the following: NSDictionary *resultsDictionary = [jsonString objectFromJsonString]; //Once you have your dictionary, you can inspect it using the objectForKey method to get objects out of it. //[self stringAnalyst:pageSource]; for http://maps.google.com/geo? NSDictionary *resultsDictionary = [pageSource objectFromJSONString]; NSArray* addressArray1 = [resultsDictionary objectForKey:@"Placemark"]; NSLog(@"test"); for (int i = 0; i< addressArray1.count; i++) { NSDictionary* temp = [addressArray1 objectAtIndex:i]; NSString* address = [temp objectForKey:@"address"]; NSLog(@"%@", address); }
posted on 2012-07-12 09:29 myprecious 阅读(177) 评论(0) 编辑 收藏 举报