JSON解析
2015-12-12 16:45
841 查看
JSON数据结构解析
// 路径 NSString *path = [[NSBundle mainBundle] pathForResource:@"area" ofType:@"json"]; // 获取数据 NSData *data = [NSData dataWithContentsOfFile:path]; // 用容器接收Json格式的数据 NSMutableArray *array = [NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingMutableContainers) error:nil]; self.dataArray = [NSMutableArray array]; for (NSDictionary *oneDic in array) { // NSArray *cityArray = oneDic[@"cityList"]; // // [self.dataDic setObject:cityArray forKey:oneDic[@"province"]]; CityModel *model = [[CityModel alloc] init]; [model setValuesForKeysWithDictionary:oneDic]; [self.dataArray addObject:model]; [model release]; }
相关文章推荐
- js如何创建类(封装)
- javascript性能优化之DOM交互操作实例分析
- [转]JSON 入门指南
- JavaScript文档碎片操作实例分析
- javascript性能优化之事件委托实例详解
- [转]DataURL与File,Blob,canvas对象之间的互相转换的Javascript
- JSP 指令
- jsp使用
- JSP处理过程
- JSP生命周期
- ng-template和html2js两种不同的模板方式
- 为什么要使用JSP?
- 什么是 JSP?
- Extjs4.2 Desktop 拖动黑色和白色的桌面图标的解决方案
- js实现归并排序
- Extjs4.2布局——Ext.container.ViewportView
- jsonp跨域请求数据实现手机号码查询实例分析
- JS 将数字转化成为货币格式
- Jsp实现文件上传(无依赖jar包)
- JSON转为字符串,字符串转为JSON格式