William Falcon
William Falcon

Reputation: 9813

Serialize JSON string SBJSON vs NSJSONSerialization vs anything else?

I am receiving this JSON string and want to know how to serialize it into a dictionary so that I can parse it into a managed object.

I have looked at a few ways (named in the title), and can't seem to find the simplest, quickest alternative. I would like to use NSJSONSerialization, but I'm not sure it is made to do this?

Code where string comes in

NSString *data = [[NSString alloc]initWithData:response encoding:NSUTF8StringEncoding];
        NSLog(@"String %@",data);

NSLog message

String [{"0":"1","id":"1","1":"re ee","name":"re ee","2":"http:\/\/ree.com\/images\/re.png","backgroundImageUrl":"http:\/\/ree.com\/images\/re.png","3":"http:\/\/ree.com\/images\/re.png","logoImageUrl":"http:\/\/ree.com\/images\/re.png"}]<br />

Thank you in advance

Upvotes: 2

Views: 3596

Answers (1)

MasterBeta
MasterBeta

Reputation: 604

JSONKit is what your are looking for.

Besides the ease of use, it's quicker than SBJSon, even quicker than NSJSONSerialization.

For your example, your can get an array like this:

NSArray* arrayFromJson = [data objectFromJSONString];
NSString* id = arrayFromJson[0][@"id"];

Easy, huh?

Upvotes: 1

Related Questions