iOS之NSJSONReadingOptions的三个选项
2016-06-23 15:50
363 查看
定义如下
官方文档
翻译
<span style="color:#006600;">/*
NSJSONReadingMutableContainers
// 指定数组和自定创建为可变的对象
Specifies that arrays and dictionaries are created as mutable objects.
Available in iOS 5.0 and later.
NSJSONReadingMutableLeaves
// 指定返回json对象内部的字符串为可变字符串的实例
Specifies that leaf strings in the JSON object graph are created as instances of NSMutableString.
Available in iOS 5.0 and later.
NSJSONReadingAllowFragments
// 指定解析的时候允许最外层(最顶层)的对象可以不是一个数组或字典对象也是可以的
Specifies that the parser(解析) should allow top-level objects that are not an instance of NSArray or NSDictionary.
Available in iOS 5.0 and later.
*/</span>
三个选项是可以结合同时使用的
typedef NS_OPTIONS(NSUInteger, NSJSONReadingOptions) { NSJSONReadingMutableContainers = (1UL << 0), NSJSONReadingMutableLeaves = (1UL << 1), NSJSONReadingAllowFragments = (1UL << 2) }
官方文档
Constants NSJSONReadingMutableContainers Specifies that arrays and dictionaries are created as mutable objects. Available in iOS 5.0 and later. NSJSONReadingMutableLeaves Specifies that leaf strings in the JSON object graph are created as instances of NSMutableString. Available in iOS 5.0 and later. NSJSONReadingAllowFragments Specifies that the parser should allow top-level objects that are not an instance of NSArray or NSDictionary. Available in iOS 5.0 and later.
翻译
<span style="color:#006600;">/*
NSJSONReadingMutableContainers
// 指定数组和自定创建为可变的对象
Specifies that arrays and dictionaries are created as mutable objects.
Available in iOS 5.0 and later.
NSJSONReadingMutableLeaves
// 指定返回json对象内部的字符串为可变字符串的实例
Specifies that leaf strings in the JSON object graph are created as instances of NSMutableString.
Available in iOS 5.0 and later.
NSJSONReadingAllowFragments
// 指定解析的时候允许最外层(最顶层)的对象可以不是一个数组或字典对象也是可以的
Specifies that the parser(解析) should allow top-level objects that are not an instance of NSArray or NSDictionary.
Available in iOS 5.0 and later.
*/</span>
三个选项是可以结合同时使用的
相关文章推荐
- asp对复杂json的解析一定要注意要点
- JSON序列化与解析原生JS方法且IE6和chrome测试通过
- Android 解析JSON对象及实例说明
- 收集json解析的四种方法分享
- Android中JSON数据的解析
- java代码解析json对象获取json对象属性值
- 学习json post请求和json解析
- Android json详解
- swift JSON字符串解析 json parse / json decode
- json解析效率对比
- 什么是json以及json解析
- Cocos2d/x 解析服务器JSON数据
- Json与对象的相互转换
- 有没有人可以帮我解析一下下面的json
- android解析json串
- 基本HTTP请求+JSON解析+发送异步请求
- Gson 转换树型结构的实例
- json解析简单事例
- Volley完全解析
- 如何使用json-lib解析有2层嵌套的list数据,然后放到对应的bean中