У меня есть следующие данные, и я хочу напечатать список элементов со следующей структурой.
Дайте мне знать, как я могу это сделать.
Я не могу получить данные, используяследующий синтаксис.
/* Data to Row Json from URL*/
NSString *MyRowJson = [NSString stringWithContentsOfURL:url
encoding:NSUTF8StringEncoding error:nil];
/* Copy data to Items from MyRowJson*/
NSDictionary *items = [MyRowJson objectFromJSONStringWithParseOptions:true];
/*get the deals data*/
NSMutableArray *ResponseData = [items objectForKey:@"deals"];
/*Get the count and based on this loop through the objects.*/
NSLog(@"deals data count is %d",[ResponseData count]);
Здесь я получил исключение при печати счета.
Ниже приведена структура моих данных.
{
"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"
},
"title": "$85 For $300 Babyface Facial At Park Avenue MedSpa",
"yahoo_title": "71% off Babyface Facial",
"url": "http://yahoo.com/aff/click/?deal=AvwTADtE&key=F374EFbM",
"yahoo_url": "http://yahoo.com/new-york/livingsocial/85-for-300-babyface-facial-at-park-avenue-medspa/",
"mobile_url": "http://m.yahoo.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://yahoo.com/new-york/"
},
"tags": [
{
"name": "Facial",
"slug": "facial",
"url": "http://yahoo.com/new-york/deals/facial/"
},
{
"name": "Spa",
"slug": "spa",
"url": "http://yahoo.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,
"state": NY,
"zip_code": "11211"
}
]
},
"source": {
"name": "LivingSocial",
"slug": "livingsocial",
"paid": 0,
"url": "http://yahoo.com/new-york/livingsocial"
}
}
]
}
}