标签:
NSDictionary to jsonString
[self DataTOjsonString:dic]
-(NSString*)DicToJsonString:(id)object
{
NSString *jsonString = nil;
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:object
options:NSJSONWritingPrettyPrinted //Pass 0 if you don‘t care about the readability of the generated string
error:&error];
if (! jsonData) {
NSLog(@"Got an error: %@", error);
} else {
jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
return jsonString;
}
iOS不使用JSONKit做Dic到JsonString的转换
标签:
原文地址:http://www.cnblogs.com/decwang/p/4886130.html