oc解析JSON文件

时间:2014-10-09 22:16:17   收藏:0   阅读:169

1利用NSBundle 取得json文件路径

 NSString *path=[[NSBundle mainBundle]pathForResource:@"help.json" ofType:nil];

 2把文件转成NSData

NSData *data=[NSData dataWithContentsOfFile:path];

3利用NSJSONSerialization把data解析成数组或字典类型

NSArray *dicArray=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!