现在的位置: 首页 > 综合 > 正文

iOS: Jsonkit

2013年10月08日 ⁄ 综合 ⁄ 共 549字 ⁄ 字号 评论关闭

1. Download jsonkit from https://github.com/johnezang/JSONKit 

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

3. if use ARC, update following setting

4 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 );

抱歉!评论已关闭.