开发者

Iphone JSON-Framework

is posible using JSON-Framework for Iphone to know 开发者_开发问答if a tag exists inside the JSON like in JAVA with the function hasTag(String)?


If by tag you mean name/key and you’re using SBJSON, use -objectForKey: and test if the return value is nil. For instance, if person is an NSDictionary instance returned by the JSON parser and it can optionally contain a nickname,

if ([person objectForKey:@"nickname"] != nil)
{
    // `nickname' is available; do something with it
}


The way I think to do it is to convert your JSON Object to an NSDictionary and after that use the method -(NSArray *)allKeys, or -(NSArray *)allValues depending what you want. It returns an array with all the keys (or values) inside the object. You can then compare the keys with the one you want to find.

Hope it helps you.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜