关于NSJSONReadingOptions参数的含义
来源:互联网 发布:ubuntu kylin 下载 编辑:程序博客网 时间:2024/06/06 19:44
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation start];
NSLog(@"request======%@",request);
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject)
{
// NSJSONReadingMutableContainers = (1UL << 0),
// NSJSONReadingMutableLeaves = (1UL << 1),
// NSJSONReadingAllowFragments = (1UL << 2)
NSData *data=(NSData *)responseObject;
NSError *error=nil;
NSDictionary *dicData1=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error ];
NSDictionary *dicData2=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error ];
NSDictionary *dicData3=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error ];
NSLog(@"解析成功 ===1=%@===2==%@====3==%@",dicData1,dicData2,dicData3);
} failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
NSLog(@"解析失败 ====%@",error);
}];
代码输出没有多大区别,我的英文不太好,看苹果官方文档上说,
似乎是 第一个给数组或字典,第二选项为 可变字符,第三项为 不属于数组、字典。接收。
NSJSONReadingMutableContainers
Specifies that arrays and dictionaries are created as mutable objects. // 创建可变的数组或字典 接收
NSJSONReadingMutableLeaves
Specifies that leaf strings in the JSON object graph are created as instances of NSMutableString. // 指定在JSON对象可变字符串被创建为NSMutableString的实例
NSJSONReadingAllowFragments
Specifies that the parser should allow top-level objects that are not an instance of NSArray or NSDictionary // 指定解析器应该允许不属于的NSArray或NSDictionary中的实例顶层对象
可是我测试的 每一项都用字典接收,系统也没有给我报错。难道这是给返回的data类型有关,如果返回的是字典或数组,就用第一项
如有误,请指正。
[operation start];
NSLog(@"request======%@",request);
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject)
{
// NSJSONReadingMutableContainers = (1UL << 0),
// NSJSONReadingMutableLeaves = (1UL << 1),
// NSJSONReadingAllowFragments = (1UL << 2)
NSData *data=(NSData *)responseObject;
NSError *error=nil;
NSDictionary *dicData1=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error ];
NSDictionary *dicData2=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error ];
NSDictionary *dicData3=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error ];
NSLog(@"解析成功 ===1=%@===2==%@====3==%@",dicData1,dicData2,dicData3);
} failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
NSLog(@"解析失败 ====%@",error);
}];
代码输出没有多大区别,我的英文不太好,看苹果官方文档上说,
似乎是 第一个给数组或字典,第二选项为 可变字符,第三项为 不属于数组、字典。接收。
NSJSONReadingMutableContainers
Specifies that arrays and dictionaries are created as mutable objects. // 创建可变的数组或字典 接收
NSJSONReadingMutableLeaves
Specifies that leaf strings in the JSON object graph are created as instances of NSMutableString. // 指定在JSON对象可变字符串被创建为NSMutableString的实例
NSJSONReadingAllowFragments
Specifies that the parser should allow top-level objects that are not an instance of NSArray or NSDictionary // 指定解析器应该允许不属于的NSArray或NSDictionary中的实例顶层对象
可是我测试的 每一项都用字典接收,系统也没有给我报错。难道这是给返回的data类型有关,如果返回的是字典或数组,就用第一项
如有误,请指正。
0 0
- 关于NSJSONReadingOptions参数的含义
- 关于NSJSONReadingOptions参数的含义
- 关于NSJSONReadingOptions参数的含义
- 关于NSJSONReadingOptions参数
- NSJSONReadingOptions 含义解释
- NSJSONReadingOptions参数说明
- NSJSONReadingOptions
- 关于GetUserName的用法及参数含义
- 关于LayoutInflater 的inflate方法参数的含义
- 关于java方法中Object... args参数的含义
- 关于GRUB中的rhgb以及quiet参数的含义
- 关于java方法中Object... args参数的含义
- 参数的含义
- ZedGraph参数的含义
- S参数的含义
- SqlHelper的参数含义
- ...的可变参数含义
- main参数的含义
- 二分算法总结
- win7 批量重命名
- Linux——物理卷、卷组、逻辑卷
- Android中的Loaders机制
- java基础_从键盘输入两个整数,求最大公约数
- 关于NSJSONReadingOptions参数的含义
- android 中国天气网天气预报
- VS2010 error LNK1123
- IOS8下利用自动布局实现键盘的弹出效果
- 通过了架构师考试
- JAVA-接口 抽象类 内部类 匿名类
- 新一代编程:scala泛函编程技术-唠叨
- torch7-- errors using gfx in the tutorial--Cannot find module 'pty.js'--[gfx.js] rendering cell
- Android 音乐播放器的开发教程(十一)SQLite的使用及最近播放的实现 ----- 小达