json - object 类互转

一 jsonstring 转化为object类

NSString *jsonStr = @"..........";

NSData *jsonData = [jsonStr dataUsingEncoding:NSUTF8StringEncoding];

NSError *errorJson;

id noSummary = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableLeaves error:&errorJson];


二 object类转为jsonstr

NSData * jsonData = [NSJSONSerialization dataWithJSONObject:@“object 类” options:0 error:nil];

NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

你可能感兴趣的:(json - object 类互转)