views:

69

answers:

1

How can I check if a field exists?

+1  A: 

Depends on how you get your return value, I'll assume it's a dictionary here, so you'll call

NSDictionary* json = [parser objectWithString:yourString error: nil];

Where yourString is the JSON string to parse, and parser is your SBJSON* object. This just gives you a dictionary, so you handle it the normal way, to test if a field named "blah" exists:

if ([json objectForKey:@"blah"] != nil)

See the reference material for NSDictionary for more information, it's just a normal dictionary object.

Travis