Fetching specific Json data with NSDictionnary - ios

I would like to fetch specific values in NSDictionnary with json data.
I would like to only fetch the first value for key "windspeedMiles" for example (in current_condition).
My Json data I've fetch is :
{
"data": {
"nearest_area": [
{
"distance_miles": "0.0",
"latitude": "54.500",
"longitude": "-8.500"
}
],
"request": [
{
"query": "Lat 54.50 and Lon -8.50",
"type": "LatLon"
}
],
"weather": [
{
"date": "2014-12-09",
"hourly": [
{
"cloudcover": "59",
"humidity": "84",
"precipMM": "0.1",
"pressure": "1024",
"sigHeight_m": "3.1",
"swellDir": "290",
"swellHeight_m": "3.0",
"swellPeriod_secs": "12.6",
"tempC": "5",
"tempF": "41",
"time": "0",
"visibility": "10",
"waterTemp_C": "12",
"waterTemp_F": "53",
"weatherCode": "116",
"weatherIconUrl": [
{
"value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png"
}
],
"winddir16Point": "SSW",
"winddirDegree": "204",
"windspeedKmph": "34",
"windspeedMiles": "21"
},
{
"cloudcover": "84",
"humidity": "87",
"precipMM": "0.1",
"pressure": "1020",
"sigHeight_m": "0.6",
"swellDir": "240",
"swellHeight_m": "0.1",
"swellPeriod_secs": "12.4",
"tempC": "6",
"tempF": "42",
"time": "300",
"visibility": "10",
"waterTemp_C": "12",
"waterTemp_F": "53",
"weatherCode": "119",
"weatherIconUrl": [
{
"value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0003_white_cloud.png"
}
],
"winddir16Point": "SSW",
"winddirDegree": "193",
"windspeedKmph": "45",
"windspeedMiles": "28"
},
{
"cloudcover": "75",
"humidity": "91",
"precipMM": "0.4",
"pressure": "1016",
"sigHeight_m": "3.1",
"swellDir": "290",
"swellHeight_m": "3.0",
"swellPeriod_secs": "11.3",
"tempC": "7",
"tempF": "44",
"time": "600",
"visibility": "2",
"waterTemp_C": "12",
"waterTemp_F": "53",
"weatherCode": "266",
"weatherIconUrl": [
{
"value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png"
}
],
"winddir16Point": "SSW",
"winddirDegree": "193",
"windspeedKmph": "54",
"windspeedMiles": "34"
},
{
"cloudcover": "0",
"humidity": "93",
"precipMM": "0.8",
"pressure": "1011",
"sigHeight_m": "1.0",
"swellDir": "250",
"swellHeight_m": "0.2",
"swellPeriod_secs": "10.6",
"tempC": "16",
"tempF": "61",
"time": "900",
"visibility": "10",
"waterTemp_C": "12",
"waterTemp_F": "53",
"weatherCode": "113",
"weatherIconUrl": [
{
"value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png"
}
],
"winddir16Point": "SSW",
"winddirDegree": "202",
"windspeedKmph": "62",
"windspeedMiles": "39"
},
{
"cloudcover": "98",
"humidity": "95",
"precipMM": "6.6",
"pressure": "1006",
"sigHeight_m": "3.7",
"swellDir": "290",
"swellHeight_m": "3.6",
"swellPeriod_secs": "11.0",
"tempC": "18",
"tempF": "65",
"time": "1200",
"visibility": "7",
"waterTemp_C": "12",
"waterTemp_F": "53",
"weatherCode": "302",
"weatherIconUrl": [
{
"value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0018_cloudy_with_heavy_rain.png"
}
],
"winddir16Point": "SW",
"winddirDegree": "220",
"windspeedKmph": "64",
"windspeedMiles": "40"
},
{
"cloudcover": "89",
"humidity": "95",
"precipMM": "8.3",
"pressure": "1003",
"sigHeight_m": "4.3",
"swellDir": "290",
"swellHeight_m": "4.0",
"swellPeriod_secs": "10.9",
"tempC": "19",
"tempF": "65",
"time": "1500",
"visibility": "5",
"waterTemp_C": "12",
"waterTemp_F": "53",
"weatherCode": "308",
"weatherIconUrl": [
{
"value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0018_cloudy_with_heavy_rain.png"
}
],
"winddir16Point": "SW",
"winddirDegree": "234",
"windspeedKmph": "60",
"windspeedMiles": "38"
},
{
"cloudcover": "49",
"humidity": "73",
"precipMM": "1.5",
"pressure": "1004",
"sigHeight_m": "5.7",
"swellDir": "290",
"swellHeight_m": "5.3",
"swellPeriod_secs": "10.8",
"tempC": "7",
"tempF": "45",
"time": "1800",
"visibility": "10",
"waterTemp_C": "12",
"waterTemp_F": "53",
"weatherCode": "353",
"weatherIconUrl": [
{
"value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0009_light_rain_showers.png"
}
],
"winddir16Point": "W",
"winddirDegree": "261",
"windspeedKmph": "66",
"windspeedMiles": "41"
},
{
"cloudcover": "58",
"humidity": "73",
"precipMM": "0.5",
"pressure": "1005",
"sigHeight_m": "7.2",
"swellDir": "290",
"swellHeight_m": "6.7",
"swellPeriod_secs": "10.6",
"tempC": "5",
"tempF": "42",
"time": "2100",
"visibility": "10",
"waterTemp_C": "12",
"waterTemp_F": "53",
"weatherCode": "353",
"weatherIconUrl": [
{
"value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0009_light_rain_showers.png"
}
],
"winddir16Point": "W",
"winddirDegree": "260",
"windspeedKmph": "79",
"windspeedMiles": "49"
}
],
"maxtempC": "19",
"mintempC": "5"
}
]
}
}
Here is my code :
Reports.m :
#import "Reports.h"
#interface Reports ()
#end
#implementation Reports
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *url = [NSURL URLWithString:#"http://api.worldweatheronline.com/free/v2/weather.ashx?q=Bundoran&format=json&num_of_days=5&key=e1caa114b7fba6f5bcea272e1fc77"];
NSData *data = [NSData dataWithContentsOfURL:url];
NSDictionary *dico = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
NSDictionary *wind = [dico objectForKey:#"windspeedMiles"];
NSLog(#"The current windspeedMiles is : %#", wind);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end

To grab that specific value in the structure you posted, you would access:
[[[[dico objectForKey:#"data"] objectForKey:#"current_condition"] objectAtIndex:0] objectForKey:#"windspeedMiles"]
You just need to look at your structure. When you get your dictionary with the JSONObjectWithData it will give you an NSDictionary for every set of curly braces, and an NSArray for every set of square ones.
Because everything in your JSON is a sub-object of "Data", I would recommend creating your original NSDictionary as:
NSDictionary *dico = [[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil] objectForKey:#"data"];
This way you don't have to keep referencing the "data" dictionary.

Your intended key resides in a nested NSDictionary object, so you can't retrieve it using:
NSDictionary *wind = [dico objectForKey:#"windspeedMiles"];
NSLog(#"The current windspeedMiles is : %#", wind);
Use:
NSDictionary *wind = [dico[#"data"][#"condition"] objectAtIndex:0];
NSLog(#"The current windspeedMiles is : %#", wind[#"windspeedMiles"]);

Related

Append Json Data in Array of Array(2D Array) in Swift [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
{
"status": 200,
"message": "Success!",
"result": {
"LessonDetail": [
{
"id": 78,
"lessonjs": "<script src=\"https://learnspeakthai.com/js/lesson.js\" ></script>",
"name": "Question words #3: What?",
"code": "ST1C2L026",
"chapter_id": "12",
"sort_order": "25",
"content_top": "",
"image": "https://learnspeakthai.com/uploads/images/lesson/lesson_thumb/8b2cbbca4a711009806b915971478cb54b2ab0d1.jpg",
"show_tone_practice": "0",
"tone_practice_shown": "None",
"tone_practise_data": "",
"show_slideshow": "1",
"active": "1",
"created_at": "2011-07-28T02:51:34.000000Z",
"updated_at": "2014-10-24T20:24:17.000000Z",
"pdf": "",
"is_practise_data": 0
}
],
"SubLesson": [
{
"id": 86,
"name": "Question words 3: What?",
"show_name": "0",
"code": "ST1C2L027",
"lesson_id": "78",
"sort_order": "5",
"content_top": "‘³A-ry?’ = ‘what?’ It is always used at the end of sentence.",
"slide": [
{
"id": 321,
"sub_lesson_id": "86",
"code": "ST1C2L028",
"isaana": "³A-ry",
"thai": "อะไร",
"english": "What? ",
"english_word_order": "",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/34322cde0baa04df7ed58295863e390c7a489a98.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/ff791dbc630a4407eec2d4bdb4cbf677fac820bb.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/ed99dca146d83b40c8a91b1a2cc58844fa9d8162.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/5ca41fb350d2713194b00071fab749d36d376f8c.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T02:55:06.000000Z",
"updated_at": "2011-07-28T02:55:21.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 322,
"sub_lesson_id": "86",
"code": "ST1C2L029",
"isaana": "(Kun) cªheu ³a-ry?",
"thai": "คุณชื่ออะไร",
"english": "What’s your name?",
"english_word_order": "(You name what?)",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/fff77db9e63b1ed203ef186c1252dee9ee47f1e6.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/85315f3e7892fdefff80dbc17a140fed7a1a0812.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/158079fe8d6aab8d95201d2c945a378b971a5e04.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/d9f7c4170a13336b95846b995add06f3537e6730.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T02:56:23.000000Z",
"updated_at": "2011-08-19T00:20:38.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 323,
"sub_lesson_id": "86",
"code": "ST1C2L030",
"isaana": "Cªheu B°orb",
"thai": "ชื่อบ๊อบ",
"english": "My name is Bob ",
"english_word_order": "(Name Bob)",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/783d893e197d718c9d32624cf6aa6eff25113dc2.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/fae572b408441871d16d9335675f88895c533f4e.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/7b80d533c30f9d7839a1cd5f058c10092960dcf8.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/57ce04c653580cdf525af9b49d8deb19f49c9786.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T02:58:00.000000Z",
"updated_at": "2011-07-28T02:58:17.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 324,
"sub_lesson_id": "86",
"code": "ST1C2L031",
"isaana": "An-n°ee r§iak w§ah ³a-ry?",
"thai": "อันนี้เรียกว่าอะไร",
"english": "What’s this called?",
"english_word_order": "(This called what?)",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/8244e536e5bcd1f0383b322f0df04a31926888f2.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/0c31968d79a921bf8b2810d8b05b9d01c4f6898f.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/394021ec2ff89c15a607ce3fd31ba0835115b84a.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/9034801d15fb058ea4a2bc0ba545e92cc3ec63a2.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T02:59:24.000000Z",
"updated_at": "2011-07-28T03:00:02.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 325,
"sub_lesson_id": "86",
"code": "ST1C2L032",
"isaana": " R§iak w§ah d§ton °my ",
"thai": " เรียกว่าต้นไม้ ",
"english": "It’s called a tree",
"english_word_order": "",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/2725e831aaf141324cc62dc61300b95dd544d487.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/b95be383542085e2c3ef1500c86c7c432c8155f9.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/e66433b0437f6b1b6d0f65b61c8b13b4e27fd57d.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/88b3abbec52de4dc667cba0b2fc4db1e1ffc42cb.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T03:01:02.000000Z",
"updated_at": "2018-05-15T09:20:24.000000Z",
"language_name": "Thai",
"language_code": "TH"
}
],
"content_bottom": "",
"image": "",
"active": "1",
"created_at": "2011-07-28T02:54:09.000000Z",
"updated_at": "2011-08-08T03:51:52.000000Z"
},
{
"id": 87,
"name": "add the polite particle ‘³na’",
"show_name": "0",
"code": "ST1C2L033",
"lesson_id": "78",
"sort_order": "10",
"content_top": "For politeness, when you use the word ‘what?’ on its own you should always add the polite particle ‘³na’. Note: This is a different polite particle than the ‘°na’ used in conjunction with ‘k°rap’ / ‘§ka’. ",
"slide": [
{
"id": 321,
"sub_lesson_id": "86",
"code": "ST1C2L028",
"isaana": "³A-ry",
"thai": "อะไร",
"english": "What? ",
"english_word_order": "",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/34322cde0baa04df7ed58295863e390c7a489a98.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/ff791dbc630a4407eec2d4bdb4cbf677fac820bb.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/ed99dca146d83b40c8a91b1a2cc58844fa9d8162.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/5ca41fb350d2713194b00071fab749d36d376f8c.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T02:55:06.000000Z",
"updated_at": "2011-07-28T02:55:21.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 322,
"sub_lesson_id": "86",
"code": "ST1C2L029",
"isaana": "(Kun) cªheu ³a-ry?",
"thai": "คุณชื่ออะไร",
"english": "What’s your name?",
"english_word_order": "(You name what?)",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/fff77db9e63b1ed203ef186c1252dee9ee47f1e6.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/85315f3e7892fdefff80dbc17a140fed7a1a0812.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/158079fe8d6aab8d95201d2c945a378b971a5e04.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/d9f7c4170a13336b95846b995add06f3537e6730.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T02:56:23.000000Z",
"updated_at": "2011-08-19T00:20:38.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 323,
"sub_lesson_id": "86",
"code": "ST1C2L030",
"isaana": "Cªheu B°orb",
"thai": "ชื่อบ๊อบ",
"english": "My name is Bob ",
"english_word_order": "(Name Bob)",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/783d893e197d718c9d32624cf6aa6eff25113dc2.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/fae572b408441871d16d9335675f88895c533f4e.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/7b80d533c30f9d7839a1cd5f058c10092960dcf8.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/57ce04c653580cdf525af9b49d8deb19f49c9786.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T02:58:00.000000Z",
"updated_at": "2011-07-28T02:58:17.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 324,
"sub_lesson_id": "86",
"code": "ST1C2L031",
"isaana": "An-n°ee r§iak w§ah ³a-ry?",
"thai": "อันนี้เรียกว่าอะไร",
"english": "What’s this called?",
"english_word_order": "(This called what?)",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/8244e536e5bcd1f0383b322f0df04a31926888f2.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/0c31968d79a921bf8b2810d8b05b9d01c4f6898f.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/394021ec2ff89c15a607ce3fd31ba0835115b84a.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/9034801d15fb058ea4a2bc0ba545e92cc3ec63a2.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T02:59:24.000000Z",
"updated_at": "2011-07-28T03:00:02.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 325,
"sub_lesson_id": "86",
"code": "ST1C2L032",
"isaana": " R§iak w§ah d§ton °my ",
"thai": " เรียกว่าต้นไม้ ",
"english": "It’s called a tree",
"english_word_order": "",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/2725e831aaf141324cc62dc61300b95dd544d487.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/b95be383542085e2c3ef1500c86c7c432c8155f9.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/e66433b0437f6b1b6d0f65b61c8b13b4e27fd57d.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/88b3abbec52de4dc667cba0b2fc4db1e1ffc42cb.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T03:01:02.000000Z",
"updated_at": "2018-05-15T09:20:24.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 326,
"sub_lesson_id": "87",
"code": "ST1C2L033a",
"isaana": "³A-ry ³na?",
"thai": "อะไรน่ะ",
"english": "What? / pardon?",
"english_word_order": "What p.p.? ",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/c2e01e9bdc3455275a60fc58640fef574920931a.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/1c9490fdc1ae25dacdecba8d5054b8bc2e116595.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/c96b08c9ee6afdd3db503abb83dbec673768284b.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/dbfede0423eb13e4fae61f0bfe3f45ef52602868.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T03:04:40.000000Z",
"updated_at": "2021-02-16T21:57:32.000000Z",
"language_name": "Thai",
"language_code": "TH"
}
],
"content_bottom": "",
"image": "",
"active": "1",
"created_at": "2011-07-28T03:03:11.000000Z",
"updated_at": "2021-02-16T21:55:34.000000Z"
}
],
"GameList": [
{
"id": 1189,
"name": "Question words #1: Matching",
"code": "ST1C2G001a",
"chapter_id": "12",
"lesson_id": "78",
"content_top": "",
"game_type": "matching",
"word_source": "selection_from_all",
"words_to_display": "10",
"sort_order": "5",
"active": "1",
"is_free": 0,
"is_subscription": 1,
"created_at": "2014-10-07T06:38:48.000000Z",
"updated_at": "2014-10-07T10:25:07.000000Z"
},
{
"id": 1190,
"name": "Question words #2: Flash card",
"code": "ST1C2G001b",
"chapter_id": "12",
"lesson_id": "78",
"content_top": "",
"game_type": "flashcard",
"word_source": "selection_from_all",
"words_to_display": "10",
"sort_order": "6",
"active": "1",
"is_free": 0,
"is_subscription": 1,
"created_at": "2014-10-07T06:57:22.000000Z",
"updated_at": "2014-10-07T10:25:38.000000Z"
}
],
"Slideshow": [
{
"id": 321,
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/ff791dbc630a4407eec2d4bdb4cbf677fac820bb.jpg",
"slide": "https://learnspeakthai.com/uploads/images/slide/34322cde0baa04df7ed58295863e390c7a489a98.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/ed99dca146d83b40c8a91b1a2cc58844fa9d8162.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/5ca41fb350d2713194b00071fab749d36d376f8c.mp3"
},
{
"id": 322,
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/85315f3e7892fdefff80dbc17a140fed7a1a0812.jpg",
"slide": "https://learnspeakthai.com/uploads/images/slide/fff77db9e63b1ed203ef186c1252dee9ee47f1e6.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/158079fe8d6aab8d95201d2c945a378b971a5e04.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/d9f7c4170a13336b95846b995add06f3537e6730.mp3"
},
{
"id": 323,
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/fae572b408441871d16d9335675f88895c533f4e.jpg",
"slide": "https://learnspeakthai.com/uploads/images/slide/783d893e197d718c9d32624cf6aa6eff25113dc2.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/7b80d533c30f9d7839a1cd5f058c10092960dcf8.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/57ce04c653580cdf525af9b49d8deb19f49c9786.mp3"
},
{
"id": 324,
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/0c31968d79a921bf8b2810d8b05b9d01c4f6898f.jpg",
"slide": "https://learnspeakthai.com/uploads/images/slide/8244e536e5bcd1f0383b322f0df04a31926888f2.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/394021ec2ff89c15a607ce3fd31ba0835115b84a.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/9034801d15fb058ea4a2bc0ba545e92cc3ec63a2.mp3"
},
{
"id": 325,
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/b95be383542085e2c3ef1500c86c7c432c8155f9.jpg",
"slide": "https://learnspeakthai.com/uploads/images/slide/2725e831aaf141324cc62dc61300b95dd544d487.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/e66433b0437f6b1b6d0f65b61c8b13b4e27fd57d.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/88b3abbec52de4dc667cba0b2fc4db1e1ffc42cb.mp3"
},
{
"id": 326,
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/1c9490fdc1ae25dacdecba8d5054b8bc2e116595.jpg",
"slide": "https://learnspeakthai.com/uploads/images/slide/c2e01e9bdc3455275a60fc58640fef574920931a.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/c96b08c9ee6afdd3db503abb83dbec673768284b.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/dbfede0423eb13e4fae61f0bfe3f45ef52602868.mp3"
}
]
}
}
I have created model for json. I want to append value in Array of english key from json.
I am doing --
var english_Array = [[String]] ()
guard let subLesson = userResponse.result?.subLesson else {return}
for i in subLesson {
english_Array.append(i.slide?[0].english ?? "" )
}
print(english_Array)
value:
[["What?"], ["What?]]
I need -
[["What?","What’s your name?","My name is Bob","What’s this called?","It’s called a tree"],
["What?","What’s your name?","My name is Bob","What’s this called?","It’s called a tree","What? / pardon?"]]
First of all there are two values for the same key "slide". You should fix it. for now lets consider they are in an array [slide1, slide2] for the key "slides".
var english_Array = [[String]] ()
for slide in subLesson.slides {
let english = slide.map { $0.english ?? "" }
english_Array.append(english_Array)
}
this should do it.

Google Sheets Formula Parse Error If,Then large formula not working

Okay, so I have checked this formula several times over in google sheets.
Brief explanation: This is a God Tier leveling system for a role-playing sheet. I had fixed several things I had found wrong with it but now I don't see anything wrong at all. It is getting very frustrating. It worked for the lower system but not for this one. I don't understand it.
=IF(C28<100, "0", IF(C28<5000, "1", IF(C28<6000, "2", IF(C28<7000, "3", IF(C28<8000, "4", IF(C28<9000, "5", IF(C28<10000, "6", IF(C28<12000, "7", IF(C28<14000, "8", IF(C28<16000, "9", IF(C28<18000, "10", IF(C28<20000, "11", IF(C28<23000, "12", IF(C28<26000, "13", IF(C28<29000, "14", IF(C28<32000, "15", IF(C28<35000, "16", IF(C28<38000, "17", IF(C28<41000, "18", IF(C28<44000, "19", IF(C28<47000, "20", IF(C28<50000, "21", IF(C28<54000, "22", IF(C28<58000, "23", IF(C28<62000, "24", IF(C28<66000, "25", IF(C28<70000, "26", IF(C28<74000, "27", IF(C28<78000, "28", IF(C28<82000, "29", IF(C28<86000, "30", IF(C28<90000, "31", IF(C28<95000, "32", IF(C28<100000, "33", IF(C28<105000, "34", IF(C28<110000, "35", IF(C28<115000, "36", IF(C28<120000, "37", IF(C28<125000, "38", IF(C28<130000, "39", IF(C40<135000, "40", IF(C28<140000, "41", IF(C28<146000, "42", IF(C28<152000, "43", IF(C28<158000, "44", IF(C28<164000, "45", IF(C28<170000, "46", IF(C28<176000, "47", IF(C28<182000, "48", IF(C28<188000, "49", IF(C28<194000, "50", IF(C28<200000, "51", IF(C28<207000, "52", IF(C28<214000, "53", IF(C28<221000, "54", IF(C28<228000, "55", IF(C28<235000, "56", IF(C28<242000, "57", IF(C28<249000, "58", IF(C28<256000, "59", IF(C28<263000, "60", IF(C28<270000, "61", IF(C28<278000, "62", IF(C28<286000, "63", IF(C28<294000, "64", IF(C28<302000, "65", IF(C28<310000, "66", IF(C28<318000, "67", IF(C28<326000. "68", IF(C28<334000, "69", IF(C28<342000, "70", IF(C28<350000, "71", IF(C28<359000, "72", IF(C28<368000, "73", IF(C28<377000, "74", IF(C28<386000, "75", IF(C28<395000, "76", IF(C28<404000, "77", IF(C28<413000, "78", IF(C28<422000, "79", IF(C28<431000, "80", IF(C28<440000, "81", IF(C28<450000, "82", IF(C28<460000, "83", IF(C28<470000, "84", IF(C28<480000, "85", IF(C28<490000, "86", IF(C28<500000, "87", IF(C28<650000, "88", IF(C28<800000, "89", IF(C28<950000, "90", IF(C28<1100000, "91", IF(C28<1250000, "92", IF(C28<1400000, "93", IF(C28<1550000, "94", IF(C28<1700000, "95", IF(C28<1850000, "96", IF(C28<2000000, "97", IF(C28<2500000, "98", IF(C28<3000000, "99", IF(C28>2999999, "100")))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
You have a period between the 67 and 68 scores :
"67", IF(C28<326000. "68",
it should be a ,

Parse this input

I get this text from the quizlet API. But how do I proceed to import it and cut it into usable pieces. I tried NSXMLParser but it didn't work. (Error 111).
How do I parse this input?
I don't need specific instructions, but a hint to where to search would be awesome.
{
"id": 415,
"url": "http://quizlet.com/415/us-state-capitals-flash-cards/",
"title": "U.S. State Capitals",
"created_by": "asuth",
"term_count": 50,
"created_date": 1144296408,
"modified_date": 1393464052,
"has_images": false,
"subjects": [
],
"visibility": "public",
"editable": "only_me",
"has_access": true,
"description": "",
"lang_terms": "en",
"lang_definitions": "en",
"has_discussion": false,
"creator": {
"username": "asuth",
"account_type": "plus",
"profile_image": "https://fbquizlet-quizletllc.netdna-ssl.com/hprofile-ak-ash1/t5/203061_1030920097_793938339_n.jpg",
"id": 1
},
],
"terms": [
{
"id": 1277349735,
"term": "Montgomery",
"definition": "Alabama",
"image": null
},
{
"id": 842513565,
"term": "Juneau",
"definition": "Alaska",
"image": null
},
{
"id": 413281845,
"term": "Phoenix",
"definition": "Arizona",
"image": null
},
{
"id": 413281846,
"term": "Little Rock",
"definition": "Arkansas",
"image": null
},
{
"id": 413281847,
"term": "Sacramento",
"definition": "California",
"image": null
},
{
"id": 413281848,
"term": "Denver",
"definition": "Colorado",
"image": null
},
{
"id": 413281849,
"term": "Hartford",
"definition": "Connecticut",
"image": null
},
{
"id": 413281850,
"term": "Dover",
"definition": "Delaware",
"image": null
},
{
"id": 413281851,
"term": "Tallahassee",
"definition": "Florida",
"image": null
},
{
"id": 413281852,
"term": "Atlanta",
"definition": "Georgia",
"image": null
},
{
"id": 413281853,
"term": "Honolulu",
"definition": "Hawaii",
"image": null
},
{
"id": 413281854,
"term": "Boise",
"definition": "Idaho",
"image": null
},
{
"id": 413281855,
"term": "Springfield",
"definition": "Illinois",
"image": null
},
{
"id": 413281856,
"term": "Indianapolis",
"definition": "Indiana",
"image": null
},
{
"id": 413281857,
"term": "Des Moines",
"definition": "Iowa",
"image": null
},
{
"id": 413281858,
"term": "Topeka",
"definition": "Kansas",
"image": null
},
{
"id": 413281859,
"term": "Frankfort",
"definition": "Kentucky",
"image": null
},
{
"id": 413281860,
"term": "Baton Rouge",
"definition": "Louisiana",
"image": null
},
{
"id": 413281861,
"term": "Augusta",
"definition": "Maine",
"image": null
},
{
"id": 413281862,
"term": "Annapolis",
"definition": "Maryland",
"image": null
},
{
"id": 413281863,
"term": "Boston",
"definition": "Massachusetts",
"image": null
},
{
"id": 413281864,
"term": "Lansing",
"definition": "Michigan",
"image": null
},
{
"id": 413281865,
"term": "St. Paul",
"definition": "Minnesota",
"image": null
},
{
"id": 413281866,
"term": "Jackson",
"definition": "Mississippi",
"image": null
},
{
"id": 413281867,
"term": "Jefferson City",
"definition": "Missouri",
"image": null
},
{
"id": 413281868,
"term": "Helena",
"definition": "Montana",
"image": null
},
{
"id": 413281869,
"term": "Lincoln",
"definition": "Nebraska",
"image": null
},
{
"id": 413281870,
"term": "Carson City",
"definition": "Nevada",
"image": null
},
{
"id": 413281871,
"term": "Concord",
"definition": "New Hampshire",
"image": null
},
{
"id": 413281872,
"term": "Trenton",
"definition": "New Jersey",
"image": null
},
{
"id": 413281873,
"term": "Santa Fe",
"definition": "New Mexico",
"image": null
},
{
"id": 413281874,
"term": "Albany",
"definition": "New York",
"image": null
},
{
"id": 413281875,
"term": "Raleigh",
"definition": "North Carolina",
"image": null
},
{
"id": 413281876,
"term": "Bismarck",
"definition": "North Dakota",
"image": null
},
{
"id": 413281877,
"term": "Columbus",
"definition": "Ohio",
"image": null
},
{
"id": 413281878,
"term": "Oklahoma City",
"definition": "Oklahoma",
"image": null
},
{
"id": 413281879,
"term": "Salem",
"definition": "Oregon",
"image": null
},
{
"id": 413281880,
"term": "Harrisburg",
"definition": "Pennsylvania",
"image": null
},
{
"id": 413281881,
"term": "Providence",
"definition": "Rhode Island",
"image": null
},
{
"id": 413281882,
"term": "Columbia",
"definition": "South Carolina",
"image": null
},
{
"id": 413281883,
"term": "Pierre",
"definition": "South Dakota",
"image": null
},
{
"id": 413281884,
"term": "Nashville",
"definition": "Tennessee",
"image": null
},
{
"id": 413281885,
"term": "Austin",
"definition": "Texas",
"image": null
},
{
"id": 413281886,
"term": "Salt Lake City",
"definition": "Utah",
"image": null
},
{
"id": 413281887,
"term": "Montpelier",
"definition": "Vermont",
"image": null
},
{
"id": 413281888,
"term": "Richmond",
"definition": "Virginia",
"image": null
},
{
"id": 413281889,
"term": "Olympia",
"definition": "Washington",
"image": null
},
{
"id": 413281890,
"term": "Charleston",
"definition": "West Virginia",
"image": null
},
{
"id": 413281891,
"term": "Madison",
"definition": "Wisconsin",
"image": null
},
{
"id": 413281892,
"term": "Cheyenne",
"definition": "Wyoming",
"image": null
}
]
}
https://api.quizlet.com/2.0/sets/415?access_token=Nzk0NzEzOGZmOTNjZDY3YmIyNTI1YTA0ZmU4NTQ1&whitespace=1
My assumption is that this part is what you are after:
"terms": [
{
"id": 1277349735,
"term": "Montgomery",
"definition": "Alabama",
"image": null
},
{
"id": 842513565,
"term": "Juneau",
"definition": "Alaska",
"image": null
},
{
"id": 413281845,
"term": "Phoenix",
"definition": "Arizona",
"image": null
},
{
"id": 413281846,
"term": "Little Rock",
"definition": "Arkansas",
"image": null
},
{
"id": 413281847,
"term": "Sacramento",
"definition": "California",
"image": null
},
{
"id": 413281848,
"term": "Denver",
"definition": "Colorado",
"image": null
},
{
"id": 413281849,
"term": "Hartford",
"definition": "Connecticut",
"image": null
},
{
"id": 413281850,
"term": "Dover",
"definition": "Delaware",
"image": null
},
{
"id": 413281851,
"term": "Tallahassee",
"definition": "Florida",
"image": null
},
{
"id": 413281852,
"term": "Atlanta",
"definition": "Georgia",
"image": null
},
{
"id": 413281853,
"term": "Honolulu",
"definition": "Hawaii",
"image": null
},
{
"id": 413281854,
"term": "Boise",
"definition": "Idaho",
"image": null
},
{
"id": 413281855,
"term": "Springfield",
"definition": "Illinois",
"image": null
},
{
"id": 413281856,
"term": "Indianapolis",
"definition": "Indiana",
"image": null
},
{
"id": 413281857,
"term": "Des Moines",
"definition": "Iowa",
"image": null
},
{
"id": 413281858,
"term": "Topeka",
"definition": "Kansas",
"image": null
},
{
"id": 413281859,
"term": "Frankfort",
"definition": "Kentucky",
"image": null
},
{
"id": 413281860,
"term": "Baton Rouge",
"definition": "Louisiana",
"image": null
},
{
"id": 413281861,
"term": "Augusta",
"definition": "Maine",
"image": null
},
{
"id": 413281862,
"term": "Annapolis",
"definition": "Maryland",
"image": null
},
{
"id": 413281863,
"term": "Boston",
"definition": "Massachusetts",
"image": null
},
{
"id": 413281864,
"term": "Lansing",
"definition": "Michigan",
"image": null
},
{
"id": 413281865,
"term": "St. Paul",
"definition": "Minnesota",
"image": null
},
{
"id": 413281866,
"term": "Jackson",
"definition": "Mississippi",
"image": null
},
{
"id": 413281867,
"term": "Jefferson City",
"definition": "Missouri",
"image": null
},
{
"id": 413281868,
"term": "Helena",
"definition": "Montana",
"image": null
},
{
"id": 413281869,
"term": "Lincoln",
"definition": "Nebraska",
"image": null
},
{
"id": 413281870,
"term": "Carson City",
"definition": "Nevada",
"image": null
},
{
"id": 413281871,
"term": "Concord",
"definition": "New Hampshire",
"image": null
},
{
"id": 413281872,
"term": "Trenton",
"definition": "New Jersey",
"image": null
},
{
"id": 413281873,
"term": "Santa Fe",
"definition": "New Mexico",
"image": null
},
{
"id": 413281874,
"term": "Albany",
"definition": "New York",
"image": null
},
{
"id": 413281875,
"term": "Raleigh",
"definition": "North Carolina",
"image": null
},
{
"id": 413281876,
"term": "Bismarck",
"definition": "North Dakota",
"image": null
},
{
"id": 413281877,
"term": "Columbus",
"definition": "Ohio",
"image": null
},
{
"id": 413281878,
"term": "Oklahoma City",
"definition": "Oklahoma",
"image": null
},
{
"id": 413281879,
"term": "Salem",
"definition": "Oregon",
"image": null
},
{
"id": 413281880,
"term": "Harrisburg",
"definition": "Pennsylvania",
"image": null
},
{
"id": 413281881,
"term": "Providence",
"definition": "Rhode Island",
"image": null
},
{
"id": 413281882,
"term": "Columbia",
"definition": "South Carolina",
"image": null
},
{
"id": 413281883,
"term": "Pierre",
"definition": "South Dakota",
"image": null
},
{
"id": 413281884,
"term": "Nashville",
"definition": "Tennessee",
"image": null
},
{
"id": 413281885,
"term": "Austin",
"definition": "Texas",
"image": null
},
{
"id": 413281886,
"term": "Salt Lake City",
"definition": "Utah",
"image": null
},
{
"id": 413281887,
"term": "Montpelier",
"definition": "Vermont",
"image": null
},
{
"id": 413281888,
"term": "Richmond",
"definition": "Virginia",
"image": null
},
{
"id": 413281889,
"term": "Olympia",
"definition": "Washington",
"image": null
},
{
"id": 413281890,
"term": "Charleston",
"definition": "West Virginia",
"image": null
},
{
"id": 413281891,
"term": "Madison",
"definition": "Wisconsin",
"image": null
},
{
"id": 413281892,
"term": "Cheyenne",
"definition": "Wyoming",
"image": null
}
]
You would use something like this to convert it to a NSDictionary:
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
Where data would be your response containing JSON. There may be some work involved to tailor up the json so that you get only the portion you want.
Here is my 'hint to where to search' : This is json, check for NSJSONSerialization tuto on the web.

Don't know how to use the JSON data returned from a web service

Apologies if this is not the right forum to ask, I couldn't think of anywhere else to take my question!
I'm trying to get the most recent weather forecast for a location using the following url http://datapoint.metoffice.gov.uk/public/data/val/wxobs/all/json/354379?res=hourly&key=47fbc7c3-dac4-424a-874d-7c8ff5b45b79
I want to get the weather type. The documentation here says that Weather Type would be a code number from 0-30. However the response from the web service (you can see for yourself following the long hyperlink above) is this:
{"SiteRep":{"Wx":{"Param":[{"name":"G","units":"mph","$":"Wind Gust"},{"name":"T","units":"C","$":"Temperature"},{"name":"V","units":"m","$":"Visibility"},{"name":"D","units":"compass","$":"Wind Direction"},{"name":"S","units":"mph","$":"Wind Speed"},{"name":"W","units":"","$":"Weather Type"},{"name":"P","units":"hpa","$":"Pressure"}]},"DV":{"dataDate":"2013-03-15T17:00:00Z","type":"Obs"}}}
Now I have no trouble reading that information into an NSDictionary object in my IOS app. But i just can't see which bit contains a code number from 0-30!
If you're wondering if i'm using the right request url, i'm pretty sure i am, i got it from the documentation here. (scroll down a little ways.)
I'm just stumped on how to extract the weather type code. I might have gotten myself completely confused and be making the wrong request, their documentation is not very user friendly. As a novice i really need help using this service, but i couldn't find any tutorials with google. Really appreciate anyone who takes the time to look! It would be such a help just to get a second opinion.
actually the response you are getting is incomplete ...complete response is as follows
{
"SiteRep": {
"Wx": {
"Param": [
{
"name": "G",
"units": "mph",
"$": "Wind Gust"
},
{
"name": "T",
"units": "C",
"$": "Temperature"
},
{
"name": "V",
"units": "m",
"$": "Visibility"
},
{
"name": "D",
"units": "compass",
"$": "Wind Direction"
},
{
"name": "S",
"units": "mph",
"$": "Wind Speed"
},
{
"name": "W",
"units": "",
"$": "Weather Type"
},
{
"name": "P",
"units": "hpa",
"$": "Pressure"
}
]
},
"DV": {
"dataDate": "2012-12-10T13:00:00Z",
"type": "Obs",
"Location": {
"i": "3772",
"lat": "51.479",
"lon": "-0.449",
"name": "HEATHROW",
"country": "ENGLAND",
"continent": "EUROPE",
"Period": [
{
"type": "Day",
"value": "2012-12-09Z",
"Rep": [
{
"D": "W",
"P": "1016",
"S": "14",
"T": "9.0",
"V": "40000",
"W": "7",
"$": "840"
},
{
"D": "W",
"P": "1016",
"S": "14",
"T": "9.0",
"V": "40000",
"W": "7",
"$": "900"
},
{
"D": "W",
"P": "1016",
"S": "10",
"T": "8.6",
"V": "45000",
"W": "7",
"$": "960"
},
{
"D": "W",
"P": "1016",
"S": "10",
"T": "8.2",
"V": "40000",
"W": "7",
"$": "1020"
},
{
"D": "WNW",
"P": "1016",
"S": "9",
"T": "7.9",
"V": "40000",
"W": "7",
"$": "1080"
},
{
"D": "WNW",
"P": "1016",
"S": "10",
"T": "7.1",
"V": "30000",
"W": "0",
"$": "1140"
},
{
"D": "WNW",
"P": "1016",
"S": "10",
"T": "6.5",
"V": "28000",
"W": "0",
"$": "1200"
},
{
"D": "WNW",
"P": "1017",
"S": "11",
"T": "6.2",
"V": "27000",
"W": "0",
"$": "1260"
},
{
"D": "W",
"P": "1017",
"S": "8",
"T": "5.2",
"V": "26000",
"W": "0",
"$": "1320"
},
{
"D": "WNW",
"P": "1017",
"S": "9",
"T": "4.8",
"V": "25000",
"W": "0",
"$": "1380"
}
]
},
{
"type": "Day",
"value": "2012-12-10Z",
"Rep": [
{
"D": "WNW",
"P": "1017",
"S": "8",
"T": "4.6",
"V": "23000",
"W": "0",
"$": "0"
},
{
"D": "WNW",
"P": "1017",
"S": "8",
"T": "4.1",
"V": "22000",
"W": "0",
"$": "60"
},
{
"D": "WNW",
"P": "1018",
"S": "9",
"T": "3.9",
"V": "22000",
"W": "0",
"$": "120"
},
{
"D": "NW",
"P": "1018",
"S": "9",
"T": "3.8",
"V": "24000",
"W": "0",
"$": "180"
},
{
"D": "NW",
"P": "1018",
"S": "10",
"T": "3.3",
"V": "26000",
"W": "0",
"$": "240"
},
{
"D": "NW",
"P": "1019",
"S": "9",
"T": "3.1",
"V": "30000",
"W": "0",
"$": "300"
},
{
"D": "NW",
"P": "1019",
"S": "9",
"T": "2.9",
"V": "30000",
"W": "0",
"$": "360"
},
{
"D": "NW",
"P": "1020",
"S": "8",
"T": "2.8",
"V": "28000",
"W": "0",
"$": "420"
},
{
"D": "NW",
"P": "1020",
"S": "6",
"T": "2.4",
"V": "19000",
"W": "0",
"$": "480"
},
{
"D": "NW",
"P": "1021",
"S": "8",
"T": "2.8",
"V": "25000",
"W": "1",
"$": "540"
},
{
"D": "NNW",
"P": "1022",
"S": "9",
"T": "3.9",
"V": "26000",
"W": "1",
"$": "600"
},
{
"D": "NNW",
"P": "1022",
"S": "8",
"T": "4.7",
"V": "25000",
"W": "1",
"$": "660"
},
{
"D": "N",
"P": "1022",
"S": "9",
"T": "5.5",
"V": "27000",
"W": "1",
"$": "720"
},
{
"D": "N",
"P": "1023",
"S": "10",
"T": "5.6",
"V": "30000",
"W": "3",
"$": "780"
}
]
}
]
}
}
}
}

How to fetch data from this json

I want this data to be displayed in the tableview . can anyone tell me how to take data in the dictionary or array and display in the table? the data is shown as under
I want to display city and custno
{
"Status": 200,
"data": [
{
"dispatch": "11111",
"locname": "Sample Company Location 1",
"add1": "226 Engleman Street",
"city": "Bardstown",
"state": "KY",
"zip": "40004",
"contacts": [
{
"id": "1",
"custno": "0000235",
"locno": "00001",
"salutation": "Mr.",
"jobtitle": "IT Manager",
"locktime": "",
"lockby": ""
},
{
"id": "11",
"custno": "0000235",
"locno": "00001",
"contact": "Greg C",
"extension": "205",
"salutation": "Mr. ",
"jobtitle": "President",
"locktime": null,
"lockby": null
},
{
"id": "12",
"custno": "0000235",
"locno": "00001",
"extension": "206",
"salutation": "Mr.",
"jobtitle": "Parts Manager",
"locktime": null,
"lockby": null
},
{
"id": "13",
"custno": "0000235",
"locno": "00001",
"extension": "202",
"salutation": "Mr.",
"jobtitle": "Service Manager",
"locktime": "",
"lockby": ""
}
],
"locationnotes": "5/20/2010 9:32:06 PM - Updated Information1111111",
"custno": "0000235",
"locno": "00001",
"calledinby": "Teresa",
"serviceagrno": "",
"dispatchnotes": "This is a test dispatch",
"pastcustomernotes": "",
"pasttechnotes": [],
"status": "Pending",
"locationimage": "/images/content/2t_1318687848_100x100.gif",
"pmstatus": "Yes"
},
{
"dispatch": "4",
"locname": "Sample Company Location 1",
"add1": "226 Engleman Street",
"city": "Bardstown",
"state": "KY",
"zip": "40004",
"contacts": [
{
"id": "1",
"custno": "0000235",
"locno": "00001",
"extension": "200",
"salutation": "Mr.",
"jobtitle": "IT Manager",
"locktime": "",
"lockby": ""
},
{
"id": "11",
"custno": "0000235",
"locno": "00001",
"phonefax": "555-555-1002",
"extension": "205",
"salutation": "Mr. ",
"jobtitle": "President",
"locktime": null,
"lockby": null
},
{
"id": "12",
"custno": "0000235",
"locno": "00001",
"extension": "206",
"salutation": "Mr.",
"jobtitle": "Parts Manager",
"locktime": null,
"lockby": null
},
{
"id": "13",
"custno": "0000235",
"locno": "00001",
"extension": "202",
"salutation": "Mr.",
"jobtitle": "Service Manager",
"locktime": "",
"lockby": ""
}
],
"locationnotes": "5/20/2010 9:32:06 PM - Updated Information1111111",
"custno": "0000235",
"locno": "00001",
"calledinby": "Teresa",
"serviceagrno": null,
"dispatchnotes": "11/3/2011 7:59 - This is a sample ATM call.",
"pastcustomernotes": "",
"pasttechnotes": [],
"status": "Pending",
"locationimage": "/images/content/2t_1318687848_100x100.gif",
"pmstatus": "No"
},
{
"dispatch": "5",
"locname": "Sample Company Location 1",
"add1": "226 Engleman Street",
"city": "Bardstown",
"state": "KY",
"zip": "40004",
"contacts": [
{
"id": "1",
"custno": "0000235",
"locno": "00001",
"contact": "Michael B",
"email": "michael#bonzahouse.com",
"phoneoffice": "502-555-1000",
"phonemobile": "502-555-0769",
"phonefax": "555-555-1002",
"extension": "200",
"salutation": "Mr.",
"jobtitle": "IT Manager",
"locktime": "",
"lockby": ""
},
{
"id": "11",
"custno": "0000235",
"locno": "00001",
"extension": "205",
"salutation": "Mr. ",
"jobtitle": "President",
"locktime": null,
"lockby": null
},
{
"id": "12",
"custno": "0000235",
"locno": "00001",
"extension": "206",
"salutation": "Mr.",
"jobtitle": "Parts Manager",
"locktime": null,
"lockby": null
},
{
"id": "13",
"custno": "0000235",
"locno": "00001",
"extension": "202",
"salutation": "Mr.",
"jobtitle": "Service Manager",
"locktime": "",
"lockby": ""
}
],
"locationnotes": "5/20/2010 9:32:06 PM - Updated Information1111111",
"custno": "0000235",
"locno": "00001",
"calledinby": "",
"serviceagrno": null,
"dispatchnotes": "",
"pastcustomernotes": "",
"pasttechnotes": [],
"status": "Pending",
"locationimage": "/images/content/2t_1318687848_100x100.gif",
"pmstatus": "Yes"
}
]
}
You need to read that into an NSDictionary with either NSJSONSerialization (only available in iOS 5 and later) or another JSON framework (I recommend TouchJSON - https://github.com/TouchCode/TouchJSON).
Here are examples:
NSJSONSerialization:
NSString *jsonString = <JSON_STRING>;
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSError *error = nil;
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:jsonData
options:0
error:&error];
TouchJSON:
NSString *jsonString = <JSON_STRING>;
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSError *error = nil;
NSDictionary *dictionary = [[CJSONDeserializer deserializer]
deserializeAsDictionary:jsonData
error:&error];
Once you have the dictionary you can then extract the information you want. In your case it looks like you want to grab the data which is an array of objects. I assume you then want to show something about those objects in a table. So here's the start of that code to get you going and then you should be able to figure out the rest:
NSArray *data = [dictionary objectForKey:#"data"];
// Then for each data object, you can get at say its `locname' attribute to show in a cell like so
NSString *locname = [[data objectAtIndex:i] objectForKey:#"locname"];

Resources