首页 > 代码库 > iOS 字符串转son  json转字符串

iOS 字符串转son  json转字符串

+ (NSString*)dictionaryToJson:(NSDictionary *)dic
{
    NSError *parseError = nil;
    NSData *jsonData = http://www.mamicode.com/[NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&parseError];
    return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
************************************
self.dataDic = [NSDictionarydictionaryWithDictionary:responseData[@"data"]];
            NSString *jsonString = responseData[@"data"][@"visitRemarks"];
            NSError *err;
            NSData *jsonData = http://www.mamicode.com/[jsonString dataUsingEncoding:NSUTF8StringEncoding];
            noteArray = [NSJSONSerialization JSONObjectWithData:jsonData  options:NSJSONReadingMutableContainers error:&err];
           

iOS 字符串转son  json转字符串