json字符串转换

1.json字符串转字典或数组
方法:+ (id)JSONObjectWithData:(NSData)dataoptions:(NSJSONReadingOptions)opterror:(NSError _Nullable *)error

``` javascriptNSString *jsonStr; NSData*jsonData = [jsonStrdataUsingEncoding:NSUTF8StringEncoding]; NSError*error; NSDictionary*dic = [NSJSONSerialization JSONObjectWithData:jsonDataoptions:NSJSONReadingMutableContainers error:&error];

2.数组或者字典转换为json字符串
【json字符串转换】方法:+ (NSData)dataWithJSONObject:(id)objoptions:(NSJSONWritingOptions)opterror:(NSError _Nullable *)error
NSData *jsonData =https://www.it610.com/article/[NSJSONSerialization dataWithJSONObject:dicoptions:(NSJSONWritingOptions)opterror:&error];

    推荐阅读