
Untitled
By: a guest on
Jun 26th, 2012 | syntax:
None | size: 1.42 KB | hits: 10 | expires: Never
Parsing JSON ( again ) in iOS
{
"trends": {
"2011-03-13 11:42:17": [
{
"events": null,
"query": "Fukushima",
"promoted_content": null,
"name": "Fukushima"
},
{
"events": null,
"query": "Rebecca Black",
"promoted_content": null,
"name": "Rebecca Black"
},
{
"events": null,
"query": "Pearl Harbour",
"promoted_content": null,
"name": "Pearl Harbour"
},
...
{
"events": null,
"query": "Magdalena Neuner",
"promoted_content": null,
"name": "Magdalena Neuner"
}
]
},
"as_of": 1300016537
}
for (int i = 0; i < [luckyNumbers count]; i++)
[text appendFormat:@"%@n", [luckyNumbers objectAtIndex:i]];
NSLog(@"%@", [[luckyNumbers objectForKey:@"trends"]);
NSString *date = [[[luckyNumbers valueForKeyPath:@"trends"] allKeys] description];
NSArray *trends = [luckyNumbers objectForKey:@"trends"];
NSLog(@"%@", [trends valueForKeyPath:date]);
NSDictionary *luckyNumbers = [responseString JSONValue];
NSArray *keys = [[luckyNumbers objectForKey:@"trends"] allKeys];
for (int i =0; i < [keys count]; i++) {
NSLog(@"%@", [keys objectAtIndex:i]);
}