Created a NSMutableDictionary
object that need to pass as a request parameter in web service. Took all the keys and values of string type.
-(void)createPayload {
NSMutableDictionary *payload = [[NSMutableDictionary alloc]init];
[payload setObject:@"T1" forKey:@"table_no"];
[payload setObject:@"18.05" forKey:@"total_amount"];
[payload setObject:@"3759121" forKey:@"order_id"];
[payload setObject:@"INR" forKey:@"currency_code"];
[payload setObject:@"VISA" forKey:@"paymentType"];
[payload setObject:@"54ds5sds6fhhh56" forKey:@"resturent_id"];
[payload setObject:@"ios" forKey:@"mode"];
NSMutableDictionary *paramDict = [[NSMutableDictionary alloc]init];
[paramDict setObject:payload forKey:@"payload"];
NSLog(@"Parameter dictionary:\n%@",paramDict);
//[self checkDataTypeOfDisctionaryObjects:payload];
}
Actual Output -
{
payload = {
"currency_code" = INR;
mode = ios;
"order_id" = 3759121;
paymentType = VISA;
"resturent_id" = 54ds5sds6fhhh56;
"table_no" = T1;
"total_amount" = "18.05";
};
}
Expected Output -
{
"payload" = {
"currency_code" = "INR";
"mode" = "ios";
"order_id" = "3759121";
"paymentType" = "VISA";
"resturent_id" = "54ds5sds6fhhh56";
"table_no" = "T1";
"total_amount" = "18.05";
};
}
But when printing logs or sending to web service only few keys and values are showing string type remaining changed into other type. My web service assuming keys and values those are inside double quote("") are string type. If any key and value do not have double quote("") web service is throwing error.
- My question is why all the keys and values do not have double quote("")? All should be same.
Note - If we check keys and values usingisKindOfClass:
will return string type. Same output in swift as well.