Parsing json in ios

Posted by gaps on Stack Overflow See other posts from Stack Overflow or by gaps
Published on 2011-11-19T09:21:49Z Indexed on 2011/11/19 9:50 UTC
Read the original article Hit count: 218

Filed under:
|
|

i have the follwing json string ,can anybody tell me how to get the value of role_name

{"response":"success","user":{"created_at":"2011-11-16T05:48:31Z","ud_id":"1234567890","last_sign_in_ip":"182.72.141.194","updated_at":"2011-11-19T08:58:27Z","account_id":21,"last_name":"dfg","role_name":"Parent","email":"[email protected]","first_name":"abc"},"status":"200"}

code for parsing is

NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"resp--- %@",responseString);

NSArray* latestLoans = [(NSDictionary*)[responseString JSONValue] objectForKey:@"user"];


NSDictionary* loan = [latestLoans objectAtIndex:0];
   NSString* name = [loan objectForKey:@"last_name"];

© Stack Overflow or respective owner

Related posts about iphone

Related posts about ios