开发者

Cocoa: SBJSON check if field exists

How can I ch开发者_StackOverfloweck if a field exists?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜