Is there an Library to support NSDictionary travelling in objective-c
Background:
After parsing json data to NSDictionary or NSArray, the expression is extremely long when you want to reach a deep attribute or value. For example:[[[book objectForKey:@"author"] objectForKey@"contact"] objectForKey:@"mobile"]
[[[[book objectForKey:@"author"] objectAtIndex:0] objectForKey"@"contact"] obj开发者_JAVA技巧ectForKey:@"mobile"]
Is there a tool to facilitate this use a query expression like "/author/contact/mobile" or "/author/[0]/contact/mobile" and used as [SimpleTraveller getValueFromDic:book, @"/author/contact/mobile"]?
Try
id obj = [book valueForKeyPath:@"author.contact.mobile"];
精彩评论