I have retrieved the following raw data from an API call and need to access it's components. At this point, I am fairly inexperienced with NSDictionaries within Objective-C and am struggling to understand the correct data types required to parse and access the individual JSON elements.
My raw JSON is as follows
[
{
"id": 1,
"forename": "Christian",
"surname": “Smith”,
"email": "christian@host.com”,
"company_id": 1,
"company_position": "Managing Director",
"twitter": “@ChristianSmith”,
"linkedin": "http://linkedin.com/Christian",
"telephone": "0123” 123 1231,
"website": "http://www.test.com”,
"profile_image": "15394045184900bcdcd027fef6b5f9f1.png",
"enabled": 1,
"admin": 0,
"created_at": "2015-01-20 14:27:33",
"updated_at": "2015-02-09 15:25:44"
},
{
"id": 2,
"forename": "Ross",
"surname": “Smith”,
"email": "ross@host.com”,
"company_id": 2,
"company_position": "Web Artisan",
"twitter": “@RossSmith”,
"linkedin": "http://www.linkedin.com/ross",
"telephone": “01213211513,
"website": "http://www.test.com,
"profile_image": "6b079f50cf977f52c8073cc0b11d9dc6.png",
"enabled": 1,
"admin": 1,
"created_at": "2015-01-20 14:27:33",
"updated_at": "2015-02-09 16:13:31"
}
]
Assuming my raw JSON is held in:
NSData *allUsersJSONData = [allUsersJSON dataUsingEncoding:NSUTF8StringEncoding];
My next step is to parse the JSON data into an accessible form. This is where my confusion arises. Conceptually, should I use an NSDictionary or an NSArray when parsing the JSON data?
I understand I can use the following code to parse the data
[NSJSONSerialization JSONObjectWithData:allUsersJSONData options:kNilOptions error:&error];
However I am struggling to understand the terminology involved and exactly what is being returned by the above function. Any explanation of the above would be greatly appreciated.