json解析

1、将附件中的文件导入工程中

2、在需要解析json的类中导入头文件#import "JSON.h"

3、开始解析:

NSString *jsonstring = @"[{\"id\":\"247\",\"title\":\"中外不同语境中的中国模式概念辨析\",\"author\":\"刘爱武\"},{\"id\":\"246\",\"title\":\"模式之惑:中国现代化观念与进程反思\",\"author\":\"贾海涛\"}]";
NSArray *arr = [jsonStr JSONValue];
 NSLog(@"list is %@", arr);
for (int i=0; i<arr.count; i++) {
                NSDictionary *dict = [arr objectAtIndex:i];
                NSString *idstr = [dict objectForKey:@"id"];
                NSString *titlestr = [dict objectForKey:@"title"];
                NSString *authorstr = [dict objectForKey:@"author"];
                NSLog(@"id=%@,title=%@,author=%@",idstr,titlestr,authorstr);
            }
 

 

 

 

 

 

你可能感兴趣的:(json解析)