iOS 系统提供的JSON解析方法

//获取文件路径

NSString *path=[[NSBundle mainBundle]pathForResource:@"sina" ofType:@"json"];

//将获取的文件转为data

NSData *data=[NSData dataWithContentsOfFile:path];

NSLog(@"%@",data);

__autoreleasing NSError *error;

//系统提供的json解析方法

NSDictionary *dic= [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error];

你可能感兴趣的:(iOS 系统提供的JSON解析方法)