开发者

Cocoa: SBJSON check if field exists

开发者 https://www.devze.com 2022-12-31 01:59 出处:网络
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

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

精彩评论

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