-4

I have this data from api in json format and now I want to display it in my android app. How can I do that?

{  
  "error":false,
  "response_code":200,
  "train_name":"NZM GARIB RATH",
  "from_station":{  
    "name":"BANDRA TERMINUS",
    "code":"BDTS"
  },
  "reservation_upto":{  
    "name":"H NIZAMUDDIN",
    "code":"NZM"
  },
  "pnr":"8459527593",
  "boarding_point":{  
    "name":"BANDRA TERMINUS",
    "code":"BDTS"
  },
  "passengers":[  
    {  
      "no":1,
      "booking_status":"W/L 77,GNWL",
      "current_status":"W/L 38"
    }
  ],
  "train_num":"12909",
  "chart_prepared":"N",
  "total_passengers":1,
  "doj":"28-7-2015",
  "to_station":{  
    "name":"H NIZAMUDDIN",
    "code":"NZM"
  },
  "class":"3A"
}
Bacteria
  • 8,406
  • 10
  • 50
  • 67

1 Answers1

0

Steps to follow,

  1. Create a HttpURLConnection or URLConnection and make a GET/POST request to the url which will return the response.

  2. Receive the JSON response as an Entity and convert it into String.

  3. Make a JSON object from the response string.

  4. Create a loop and parse all JSON data.

  5. Create your custom list adapter and put the parsed data into the array.

Reference:

How do I use the Simple HTTP client in Android?

how to parse JSONArray in android

Android Custom ListView with Images and Text – Example

Community
  • 1
  • 1
Prokash Sarkar
  • 11,723
  • 1
  • 37
  • 50