Possible Duplicate:
Iterating through NSDictionary for null value
I have a json like image, i want to replace all value string to an empty string. I see that it is similar to this question but all the value have not changed.
Possible Duplicate:
Iterating through NSDictionary for null value
I have a json like image, i want to replace all value string to an empty string. I see that it is similar to this question but all the value have not changed.
Your "<null>"
is not a null! This is a NSString.
If you want null in your JSON you should have
"someKey": null
If you want to repleace it you should use NSNull class
EDIT:
Based on screenshots in comments:
If you using this category to your Dictionary from SBJSON this is very wrong. You assume that everything you received from JSON is NSString
which is not true. If you don't and using it for every sub-dictionaty this is ok.
Change
if(object == nul)
to
if([object isKindOfClass:[NSNull class]])
or in your JSON (this is really REALLY wrong!)
if([object isKindOfClass:[NSString class]])
if([(NSString*)object isEqualToString:@"<null>"])
And please edit your original post with code. Not pase a screenshots in comments.
you can do this by using enumerateKeysAndObjectsUsingBlock:
. Here is the solution you are trying, check this link.