NSString * str = @"[ { "product_id": "228", "order_id": "475", "score": "", "images": "", "remark": "sdlakfjalskjf", "lang": "zh_cn", "member_id": "1", "order_number": "810201610271410406835", "item_id": "0" } ]";
NSData * data = [str dataUsingEncoding:NSUTF8StringEncoding];
NSArray * result = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
NSLog(@"字符串转到data,再转成json%@",result);
NSArray * a = @[
@{
@"images" : @"",
@"item_id" : @0,
@"lang" : @"zh_cn",
@"member_id" : @1,
@"order_id" : @475,
@"order_number" : @"810201610271017264145",
@"product_id" : @1151,
@"remark" : @"第一个商品",
@"score" : @""
},
@{
@"images" : @"",
@"item_id" : @0,
@"lang" : @"zh_cn",
@"member_id" : @1,
@"order_id" : @473,
@"order_number" : @"810201610271017264145",
@"product_id" : @1152,
@"remark" : @"第二个商品",
@"score" : @""
}
];
NSData * jsonData = [NSJSONSerialization dataWithJSONObject:a options:NSJSONWritingPrettyPrinted error:nil];
NSString * strdd = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
NSLog(@"json转成data,再转成字符串%@",result);
网友评论