Saturday, May 7, 2016

JSON Pershing from NSString using NSJSONSerialization in iOS-9 (Objective-c)

First you will need to convert your NSString to NSData by doing the following:
NSData *data = [stringData dataUsingEncoding:NSUTF8StringEncoding];
Now convert NSData to NSDictionary using NSJSONSerialization:
NSError* error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:data 
options:kNilOptions    error:&error];

Create NSArray OR NSDictionary:
NSArray* latestLoans = [json objectForKey:@"result"];
NSLog(@"loans: %@", latestLoans);


Post a Comment


Copyright @ 2014 Tech Tutorial .