How do I get a JSON and store it in a list?

0

I would like to receive a JSON containing multiple messages and store it in a list that contains JSON content per position

The format of JSON would be this:

[{"id":"42","data":"02\/12\/2015 12:01:21","texto":"blablabla","nome":null},
 {"id":"48","data":"02\/12\/2015 12:02:21","texto":"kkkkkkk","nome":fulano},
 {"id":"29","data":"03\/12\/2015 12:02:21","texto":"hi ha ho","nome":jhonn}]

In xCode, I'm working with Objective-C.

    
asked by anonymous 04.02.2016 / 14:28

1 answer

2

First you need to convert this string to a NSData :

NSData *data = [json dataUsingEncoding:NSUTF8StringEncoding];

And then, for a NSArray , which is a list of NSDictionary :

NSError *error;
NSArray *array = [NSJSONSerialization JSONObjectWithData: data options: nil error: &error];
    
04.02.2016 / 15:01