JSON数据(NSData)-> OC对象(Foundation Object)
- {} - > NSDictionary @{}
- [] -> NSArray @[]
- "" -> NSString @"jack"
- 10 -> NSNumber @10
- 10.5 -> NSNumber @10.5
- true -> NSNumber @1
- false -> NSNumber @0
- null -> NSNull
JSON数据(NSData) -> OC对象(Foundation Object)
// 利用NSJSONSerialization类
+ (id)JSONObjectWithData:(NSData *)data options:(NSJSONReadingOptions)opt error:(NSError **)error;
- NSJSONReadingOptions
- NSJSONReadingMutableContainers = (1UL << 0)
- NSJSONReadingMutableLeaves = (1UL << 1)
- NSJSONReadingAllowFragments
- 允许解析出来的对象不是字典或者数组,比如直接是字符串或者NSNumber
OC对象(Foundation Object)-> JSON数据(NSData)
// 利用NSJSONSerialization类
+ (NSData *)dataWithJSONObject:(id)obj options:(NSJSONWritingOptions)opt error:(NSError **)error;
格式化服务器返回的JSON数据
[dict writeToFile:@"/Users/xiaomage/Desktop/video.plist" atomically:YES];