I have created a rest service whose output is of the form
{
"id": "1905",
"groupId": "724",
"giftingId": null,
"name": "This is a great service",
}
I am using AFNetworking http client to call this service. Its output is
{
name = "This is a great service";
id = 1905;
groupId = 724;
giftingId = "<null>";
}
I am unable to parse that gifting id when its null. I simply want to parse the data to NSString? Why is it parsing the JSON as integers when they are sent as strings?
I think you are misunderstanding what you are seeing in the output. When an NSDictionary is output, it doesn’t print double quotes for any string that is all letters and number.
This is a great servicehas spaces and<null>has angle brackets.I’m pretty sure that the dictionary which prints as:
is actually:
I think the solution here is handling and detecting the NSNull.
[JSON[@"giftingId"] isEqual:[NSNull null]]should be able to detect ifgiftingIdis an NSNull.If you don’t have the lastest Xcode, then you should use
[[JSON objectForKey:@"giftingId"] isEqual:[NSNull null]]