JSON简介请移步百度百科
二进制数据转JSON枚举
typedef NS_OPTIONS(NSUInteger, NSJSONReadingOptions) {
NSJSONReadingMutableContainers = (1UL << 0),
NSJSONReadingMutableLeaves = (1UL << 1),
NSJSONReadingAllowFragments = (1UL << 2)
} API_AVAILABLE(macos(10.7), ios(5.0), watchos(2.0), tvos(9.0));
NSJSONReadingMutableContainers
Specifies that arrays and dictionaries are created as mutable objects.
(即JSON数据可解析为可变的数组或字典)
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.
(即JSON数据可以不是NSArray或NSDictionary的合法JSON对象)
JSON对象转二进制枚举
typedef NS_OPTIONS(NSUInteger, NSJSONWritingOptions) {
NSJSONWritingPrettyPrinted = (1UL << 0),
NSJSONWritingSortedKeys API_AVAILABLE(macos(10.13), ios(11.0), watchos(4.0), tvos(11.0)) = (1UL << 1)
} API_AVAILABLE(macos(10.7), ios(5.0), watchos(2.0), tvos(9.0));
NSJSONWritingPrettyPrinted
The writing option that uses white space and indentation to make the output more readable.
(即使用空格和缩进进行格式化)
NSJSONWritingSortedKeys
The writing option that sorts keys in lexicographic order.
(即对key按字典顺序进行排序)