http://blog.csdn.net/l_ch_g/article/details/8477187
例子上写的比较浅显易懂, 不过我还是稍微总结一下:
导入JSONKit.h之后
字符串转NSDictionary: 使用NSData对象方法 [nsDataObj objectFromJSONData]; 转化为NSData
NSDictionary转字符串: 使用NSDictionary的 [nsDictObj JSONData] 转化成NSData
导入JSONKIT和dylib 将json转换为NSDictionary NSString *string =@"{"name": "My Name","list": ["one","two","three"]}"; NSData* jsonData = [stringdataUsingEncoding:NSUTF8StringEncoding]; NSDictionary *resultsDictionary = [jsonDataobjectFromJSONData]; NSLog(@"55----%@",resultsDictionary); 将NSDictionary转换为 json格式的string //resultsDictionary是需要转换的dictionary NSString *string = [[NSString alloc] initWithData:[resultsDictionary JSONData] encoding:NSUTF8StringEncoding];