Darshan Sonigara Darshan Sonigara - 1 year ago 69
iOS Question

How to parse JSON in objective-C iOS

I want to parse JSON in Objective-C in iOS using AFNetworking library

"success": 1,
"row": [
"amount": 2800


arrAmount = [responseObject valueForKey:@"row"];

NSString *strAmount =[NSString stringWithFormat:@"%@", [arrAmount valueForKey:@"amount"]];

self.lblAmount.text =[NSString stringWithFormat:@"%@",strAmount];

Answer Source

Response of rowcontain array not Dictionary, so access amount from first object of Array.

NSarray *arrAmount = [responseObject objectForKey:@"row"];
if arrAmount.count > 0 {
    NSDictionary *dic = [arrAmount objectAtIndex:0];
    NSString *strAmount = [NSString stringWithFormat:@"%d", [dic objectForKey:@"amount"]];
    self.lblAmount.text = strAmount;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download