NSMutableDictionary *MDic = [[NSMutableDictionary alloc]init];
MDic[@"SSID"] = ssid;
MDic[@"Password"] = passWord;
NSData *data = [NSJSONSerialization dataWithJSONObject:MDic options:NSJSONWritingPrettyPrinted error:nil];
NSString *dataString = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
const char *a = [dataString UTF8String];
NSLog(@"************** %s",a);
通过更改 options 参数实现传递json格式的控制: 不需要格式化,将 NSJSONWritingPrettyPrinted 改为 kNilOptions
网友评论