iOS之 json数据解析
来源:互联网 发布:如何用excel做数据库 编辑:程序博客网 时间:2024/05/22 13:59
iOS 之征战json数据解析
/* { "code": "0", "message": "suss", "result": { "rst": [ { "id": "511359", "title": "【中国新闻周刊】换换会更健康吗?还是跳槽只会带给你创伤", "smalltitle": "图片来源:视觉中国", "subhead": "", "tags": "6302", "taginfo": [ { "id": "6302", "name": "跳槽", "type": "3" } ], */
最外层是字典 字典里面又是字典 字典里面是数组 数组里面又是字典
- (void)addSetData{ AFHTTPSessionManager *manger = [AFHTTPSessionManager manager]; // NSString *url = @"http://api.m.jiemian.com/cate/all.json"; NSString *url = @"http://api.m.jiemian.com/article/cate/117.json"; [manger GET:url parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) { // NSLog(@"1221212122122%@", responseObject); NSDictionary *dictionary = responseObject[@"result"]; NSArray *array = dictionary[@"rst"]; NSMutableArray *tempArray = [NSMutableArray array]; for (NSDictionary *dic in array) { NewsListModel *model = [[NewsListModel alloc]init]; [model setValuesForKeysWithDictionary:dic]; NSLog(@"%@", model.title); [tempArray addObject:model]; } } failure:^(NSURLSessionDataTask * task, NSError * error) { NSLog(@"失败%@",error.debugDescription); }];}
第二种方式
{ "code": "0", "message": "suss", "result": [ { "id": "1", "name": "商业", "show": "show_img_top", "url": "http://api.m.jiemian.com/article/cate/117.json", "img": "http://img.jiemian.com/101/original/20150515/143166967021642700.png", "manage_img": "http://img.jiemian.com/101/original/20150521/143218683092607600.png", "unistr": "117" },
最外层是字典 字典里面是数组 数组里面是字典
- (void)addOther{ AFHTTPSessionManager *manger = [AFHTTPSessionManager manager]; NSString *url = @"http://api.m.jiemian.com/cate/all.json"; [manger GET:url parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) { // NSLog(@"%@", responseObject); NSArray *array = responseObject[@"result"]; NSMutableArray *tempArray = [NSMutableArray array]; for (NSDictionary *dic in array) { NewsModel *model = [[NewsModel alloc]init]; [model setValuesForKeysWithDictionary:dic]; [tempArray addObject:model]; NSLog(@"%@", model.name); } } failure:^(NSURLSessionDataTask *task, NSError *error) { NSLog(@"失败"); }];}
1 0
- IOS数据解析之json
- iOS数据解析之json
- iOS之 json数据解析
- iOS数据解析之JSON解析
- IOS开发之Json数据解析
- iOS之数据解析 (JSON 、XML)
- IOS解析Json数据
- IOS-----> Json数据解析
- ios json数据解析
- iOS json数据解析
- ios json数据解析
- iOS解析json数据
- iOS JSON数据解析
- 23>IOS数据解析---------之JSON和XML解析
- iOS开发: 网络解析数据之JSON解析
- ios开发系列之XML解析和JSON解析数据
- 数据解析之JSON
- iOS解析之Json解析
- hdoj N!
- echarts开发流程详解
- 组合模式
- C语言的问题,关于temp参数的一些知识
- UESTC 1263-The Desire of Asuna
- iOS之 json数据解析
- c语言关于二叉树的知识和float的一些问题
- 人生在世,不在于读多少,在于读什么?
- 高并发服务端分布式系统设计概要
- 【php】 勾搭 Composer\Autoload\ClassLoader 类
- uestc 人民币的构造 1264 (打表)
- 一种单例的实现方法
- 如何快速研究透一篇 Paper 并提出有价值的问题?
- 途牛谭俊青:多数据中心状态同步&两地三中心的理论