title: Parsing nested JSON objects with JSON Framework for Objective-C
body: <p>I have the following JSON object:</p>
  
  <pre><code>{
  "response": {
      "status": 200
  },
  "messages": [
      {
          "message": {
              "user": "value"
              "pass": "value",
              "url": "value"
           }
   ]
      }
  </code></pre>
  
  <p>}</p>
  
  <p>I am using JSON-Framework (also tried JSON Touch) to parse through this and create a dictionary. I want to access the "message" block and pull out the "user", "pass" and "url" values.</p>
  
  <p>In Obj-C I have the following code:</p>
  
  <pre><code>// Create new SBJSON parser object
  SBJSON *parser = [[SBJSON alloc] init];
  
  // Prepare URL request to download statuses from Twitter
  NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:myURL]]; 
  
  // Perform request and get JSON back as a NSData object
  NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
  
  // Get JSON as a NSString from NSData response
  NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
  
  //Print contents of json-string
  NSArray *statuses = [parser objectWithString:json_string error:nil];
  NSLog(@"Array Contents: %@", [statuses valueForKey:@"messages"]);
  NSLog(@"Array Count: %d", [statuses count]);
  
  
  NSDictionary *results = [json_string JSONValue];
  NSArray *tweets = [[results objectForKey:@"messages"] objectForKey:@"message"];
  
  for (NSDictionary *tweet in tweets)
  {
      NSString *url = [tweet objectForKey:@"url"];
      NSLog(@"url is: %@",url);
  }
  </code></pre>
  
  <p>I can pull out "messages" and see all of the "message" blocks, but I am unable to parse deeper and pull out the "user", "pass", and "url".</p>