关于NSJSONReadingOptions参数的含义

简介: <span style="color:rgb(51,51,51); font-family:'Helvetica Neue',Helvetica,STheiti,微软雅黑,黑体,Arial,Tahoma,sans-serif,serif; font-size:14px; line-height:24px">  AFHTTPRequestOperation *operation = [[AF
  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类型有关,如果返回的是字典或数组,就用第一项  
 
如有误,请指正。
目录
相关文章
|
6月前
|
Java
参数
在Java中,形式参数是函数或方法的参数。形式参数是在定义函数或方法时指定的变量,它们的作用是接收函数或方法调用时传递的实际参数的值。形式参数和实际参数是不同的,形式参数是在函数或方法内部使用的,而实际参数是在函数或方法调用时传递的值。
38 1
|
8月前
|
前端开发 JavaScript
路径中“./”、“../”、“/”代表的含义
路径中“./”、“../”、“/”代表的含义
131 0
|
11月前
|
API Python
一日一技:如何正确使用 re.sub 的第二个参数
一日一技:如何正确使用 re.sub 的第二个参数
60 0
this的含义及其用法
this:代表当前对象的引用(谁调用就代表谁) this关键字主要有三个应用: 1.访问成员:
A2W W2A A2T T2A _T() 含义以及用法
A2W W2A A2T T2A _T() 含义以及用法
241 0
不定长参数作用
不定长参数作用
85 0
self.doubleSpinBox.setGeometry(QtCore.QRect(20, 25, 101, 22))参数讲解
self.doubleSpinBox.setGeometry(QtCore.QRect(20, 25, 101, 22))参数讲解
283 0
|
C++
C++函数及参数
传值->传递的是数据副本(结构、普通数据类型数据) 传地址->传递的是数据变量的地址(数组等) 传值的缺点是需要复制数据副本,数据量大可能增加内存需求,降低系统运行速度; 传地址也有传地址的不好的地方,比如在不需要修改原数据的时候,一不小心把数据修改了,造成程序的违需求性;
925 0