iOS: Jsonkit

来源:互联网 发布:孙大炮 萝莉控 知乎 编辑:程序博客网 时间:2024/05/16 03:47
1. Download jsonkit from https://github.com/johnezang/JSONKit

2. copy JSONKit.h and JSONKit.m files to your project

3.sample codes (记得import JSONKit.h)

NSString* strUrl=@"xxxx"; //it return json format string

NSURL *url=[NSURL URLWithString:strUrl];
NSMutableURLRequest *request=[[NSMutableURLRequest alloc] initWithURL:url];
NSError *err=nil;
NSData *jsonData=[NSURLConnection sendSynchronousRequest:request
returningResponse:nil
error:&err];
NSDictionary *resultsDictionary = [jsonData objectFromJSONData];
NSLog(@"resultsDictionary=%@", resultsDictionary );

原创粉丝点击