Note that there are some explanatory texts on larger screens.

plurals
  1. POHelp parsing a nested JSON object
    primarykey
    data
    text
    <p><strong>I have the following JSON</strong>:</p> <pre><code>{ "meta": { "code": 200 }, "response": { "deals": [ { "id": 32373, "date_added": "2011-01-13 12:12:50", "end_date": "2011-01-14 10:00:00", "active": 1, "discount": { "raw": 71, "formatted": "71%" }, "price": { "raw": "85.00", "formatted": "$85" }, "value": { "raw": "300.00", "formatted": "$300" }, "purchased": 82, "left": null, "title": "$85 For $300 Babyface Facial At Park Avenue MedSpa", "yipit_title": "71% off Babyface Facial", "url": "http://yipit.com/aff/click/?deal=AvwTADtE&amp;key=F374EFbM", "yipit_url": "http://yipit.com/new-york/livingsocial/85-for-300-babyface-facial-at-park-avenue-medspa/", "images": { "image_big": "http://d22nv2k05ynu7x.cloudfront.net/deal_images/deal/85-for-300-babyface-facial-at-park-avenue-medspa-1294920769_display_image.jpg", "image_small": "http://d22nv2k05ynu7x.cloudfront.net/deal_images/deal/85-for-300-babyface-facial-at-park-avenue-medspa-1294920769_small_image.jpg" }, "division": { "slug": "new-york", "name": "New York", "active": 1, "time_zone_diff": -4, "lat": "40.7142690000000000", "lon": "-74.0059730000000000", "url": "http://yipit.com/new-york/" }, "tags": [ { "name": "Facial", "slug": "facial", "url": "http://yipit.com/new-york/deals/facial/" }, { "name": "Spa", "slug": "spa", "url": "http://yipit.com/new-york/deals/spa/" } ], "business": { "name": "Park Avenue MedSpa", "url": "", "locations": [ { "address": "565 Park Ave", "locality": "New York", "phone": "212-593-8821", "lat": null, "lon": null } ] }, "source": { "name": "LivingSocial", "slug": "livingsocial", "paid": 0, "url": "http://yipit.com/new-york/livingsocial" } } ] } } </code></pre> <p><strong>Here is how I am parsing it:</strong></p> <pre><code> NSArray *deals = [[results objectForKey:@"response"] valueForKey:@"deals"]; NSLog(@"%@",[[results objectForKey:@"response"] valueForKey:@"deals"]); for(NSDictionary* deal in deals) { NSLog(@"Title: %@", [deal valueForKey:@"title"]); NSLog(@"URL: %@", [deal valueForKey:@"url"]); NSLog(@"Value: %@", [[deal valueForKey:@"value"] valueForKey:@"formatted"]); NSLog(@"Picture URL: %@", [[deal valueForKey:@"images"] valueForKey:@"image_small"]); NSLog(@"Business: %@", [[deal valueForKey:@"business"] valueForKey:@"name"]); NSLog(@"Address: %@", [[[deal valueForKey:@"business"] valueForKey:@"locations"] valueForKey:@"address"]); NSLog(@"City: %@", [[[deal valueForKey:@"business"] valueForKey:@"locations"] valueForKey:@"locality"]); NSLog(@"Phone: %@", [[[deal valueForKey:@"business"] valueForKey:@"locations"] valueForKey:@"phone"]); [items addObject:deal]; } </code></pre> <p>My logging looks good except for <strong>Address</strong>, <strong>City</strong> and <strong>Phone</strong>. Here is the log:</p> <pre><code>Title: $10 for $20 Worth of Food and Drinks at Blondies in Tempe URL: http://yipit.com/aff/click/?deal=cHBPNZ3w&amp;key=93HU7t2d Value: $20 Picture URL: http://d22nv2k05ynu7x.cloudfront.net/deal_images/deal/50-off-at-blondies-sports-bar-1298454745_small_image.jpg Business: Blondies Sports Bar Address: ( "501 S Mill Ave" ) City: ( Tempe ) Phone: ( "702-737-0444" ) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload