dic->data
NSMutableDictionary *muDic = [NSMutableDictionary dictionary];
[muDic setValue:@(89.6) forKey:@"number"];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:muDic options:kNilOptions error:nil];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
data -> dic
NSData *jsonData2 = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSError *err;
id dic = [NSJSONSerialization JSONObjectWithData:jsonData2 options:NSJSONReadingMutableContainers error:&err];
if(err) {
NSLog(@"json解析失败:%@",err);
}else{
NSLog(@"dic is %@",dic);
}
网友评论