NSDictionary类
首先要导入json类库
1.将字符串转化成字典
NSDictionary *dic = [dicStr JSONValue] ;
2.字典转化成字符串
方法
- (NSString*)dictionaryToJson:(NSDictionary *)dic
{
NSError *parseError = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&parseError];
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
NSData转化成NSString
NSString *dataStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];