Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 26th, 2012  |  syntax: None  |  size: 1.42 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Parsing JSON ( again ) in iOS
  2. {
  3.     "trends": {
  4.         "2011-03-13 11:42:17": [
  5.             {
  6.                 "events": null,
  7.                 "query": "Fukushima",
  8.                 "promoted_content": null,
  9.                 "name": "Fukushima"
  10.             },
  11.             {
  12.                 "events": null,
  13.                 "query": "Rebecca Black",
  14.                 "promoted_content": null,
  15.                 "name": "Rebecca Black"
  16.             },
  17.             {
  18.                 "events": null,
  19.                 "query": "Pearl Harbour",
  20.                 "promoted_content": null,
  21.                 "name": "Pearl Harbour"
  22.             },
  23.             ...
  24.             {
  25.                 "events": null,
  26.                 "query": "Magdalena Neuner",
  27.                 "promoted_content": null,
  28.                 "name": "Magdalena Neuner"
  29.             }
  30.         ]
  31.     },
  32.     "as_of": 1300016537
  33. }
  34.        
  35. for (int i = 0; i < [luckyNumbers count]; i++)
  36.     [text appendFormat:@"%@n", [luckyNumbers objectAtIndex:i]];
  37.        
  38. NSLog(@"%@", [[luckyNumbers objectForKey:@"trends"]);
  39.        
  40. NSString *date = [[[luckyNumbers valueForKeyPath:@"trends"] allKeys] description];
  41. NSArray *trends = [luckyNumbers objectForKey:@"trends"];
  42. NSLog(@"%@", [trends valueForKeyPath:date]);
  43.        
  44. NSDictionary *luckyNumbers = [responseString JSONValue];
  45. NSArray *keys = [[luckyNumbers objectForKey:@"trends"] allKeys];
  46.  
  47. for (int i =0; i < [keys count]; i++) {
  48.  
  49. NSLog(@"%@", [keys objectAtIndex:i]);
  50.  
  51.  
  52.     }