NSJSONReadingOptions
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 = (1UL << 0), // 返回可變?nèi)萜鳎琋SMutableDictionary或NSMutableArray
NSJSONReadingMutableLeaves = (1UL << 1), // 不僅返回的最外層是可變的, 內(nèi)部的子數(shù)值或字典也是可變對象
NSJSONReadingAllowFragments = (1UL << 2) // 返回允許JSON字符串最外層既不是NSArray也不是NSDictionary赔蒲,但必須是有效的JSON Fragment.可以是如 "10"
NSJSONWritingOptions
typedef NS_OPTIONS(NSUInteger, NSJSONWritingOptions) {
NSJSONWritingPrettyPrinted = (1UL << 0),
/* Sorts dictionary keys for output using [NSLocale systemLocale]. Keys are compared using NSNumericSearch. The specific sorting method used is subject to change.
*/
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 = (1UL << 0) //是將生成的json數(shù)據(jù)格式化輸出咪鲜,這樣可讀性高省有,不設(shè)置則輸出的json字符串就是一整行。
NSJSONWritingSortedKeys //輸出的json字符串就是一整行