iOS 系统提供的JSON解析方法

2016-03-25  本文已影响145人  yymyb

//获取文件路径

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];

上一篇 下一篇

猜你喜欢

热点阅读