NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
[dic setValue:@"2660" forKey:@"userId"];
[dic setValue:@"2660" forKey:@"cardid"];
[dic setValue:@"2660" forKey:@"cardcity"];
[dic setValue:@"2660" forKey:@"cardtype"];
[dic setValue:@"UnBindCard" forKey:@"txncode"];
[dic setValue:@"00" forKey:@"idType"];
[dic setValue:@"2660" forKey:@"idName"];
[dic setValue:@"2660" forKey:@"idNo"];
[dic setValue:@"2660" forKey:@"email"];
[dic setValue:@"2660" forKey:@"mobile"];
转化前:
Printing description of dic:
{
cardcity = 2660;
cardid = 2660;
cardtype = 2660;
email = 2660;
idName = 2660;
idNo = 2660;
idType = 00;
mobile = 2660;
txncode = UnBindCard;
userId = 2660;
}
NSData *data=[NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil];
NSString *jsonStr=[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"jsonStr is %@",jsonStr);
转化后:
Printing description of jsonStr:
{
"idType" : "00",
"idName" : "2660",
"userId" : "2660",
"cardid" : "2660",
"mobile" : "2660",
"cardtype" : "2660",
"idNo" : "2660",
"email" : "2660",
"txncode" : "UnBindCard",
"cardcity" : "2660"
}