-1

I want to take data from one of website which will be in json format and want to show it in second page of my app. How can i parse it in ios? json response is going to e like this :

{
    "response_code": 200,
    "error": false,
    "train_name": "KCG YPR EXP",
    "train_num": "17603",
    "pnr": "1234567890",
    "failure_rate": 19.346153846153847,
    "doj": "20-8-2015",
    "chart_prepared": "Y",
    "class": "SL",
    "total_passengers": 2,
    "train_start_date": {
        "month": 8,
        "year": 2015,
        "day": 20
    },
    "from_station": {
        "code": "KCG",
        "name": "KACHEGUDA"
    },
    "boarding_point": {
        "code": "KCG",
        "name": "KACHEGUDA"
    },
    "to_station": {
        "code": "YPR",
        "name": "YESVANTPUR JN"
    },
    "reservation_upto": {
        "code": "YPR",
        "name": "YESVANTPUR JN"
    },
    "passengers": [
        {
            "no": 1,
            "booking_status": "S7,58,GN",
            "current_status": "S7,58",
            "coach_position": 9
        },
        {
            "no": 2,
            "booking_status": "S7,59,GN",
            "current_status": "S7,59",
            "coach_position": 9
        }
    ]
}
Bhadresh Mulsaniya
  • 2,610
  • 1
  • 12
  • 25
pravin nagargoje
  • 70
  • 1
  • 1
  • 9

1 Answers1

0
NSError *err;
    NSURL *url=[NSURL URLWithString:@"your url"];
    NSURLRequest *req=[NSURLRequest requestWithURL:url];
    NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:nil error:&err];
    NSDictionary *json=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
Bhadresh Mulsaniya
  • 2,610
  • 1
  • 12
  • 25