0

I have JSON String like this:

{
"status":"OK",
"data":[
   {
    "page":1,
    "pages":2,
    "per_page":10,
    "count":10,
    "total":"16"
   },
   [
    {
     "sub_id":40,
     "title":"Gender",
     "katsub_id":1
   },
   {
     "sub_id":153,
     "title":"Geografi",
     "katsub_id":1
   },
   {
     "sub_id":151,
     "title":"Iklim",
     "katsub_id":1
   },
   {
     "sub_id":26,
     "title":"Indeks Pembangunan Manusia",
     "katsub_id":1
   },
   {
     "sub_id":23,
     "title":"Kemiskinan",
     "katsub_id":1
   },
   {
     "sub_id":12,
     "title":"Kependudukan",
     "katsub_id":1
   },
   {
     "sub_id":30,
     "title":"Kesehatan",
     "katsub_id":1
   },
   {
     "sub_id":5,
     "title":"Konsumsi dan Pengeluaran",
     "katsub_id":1
   },
   {
     "sub_id":152,
     "title":"Lingkungan Hidup",
     "katsub_id":1
   },
   {
     "sub_id":101,
     "title":"Pemerintahan",
     "katsub_id":1
   }
   ]
   ]
  }

How to parse this json and view the result in ListView in android. I am stuck in this part. I want "title" to be displayed in ListView, such as kemiskinan, kependudukan, lingkungan hidup, etc.

Thanks.

Eenvincible
  • 5,641
  • 2
  • 27
  • 46
  • You can refer this: http://stackoverflow.com/questions/20699627/how-to-parse-jsonarray-inside-jsonarray-in-android – Priyanka Jul 22 '16 at 08:02
  • Which library are you using? – g123k Jul 22 '16 at 08:08
  • you need to name to inside in array of another array – Arjun saini Jul 22 '16 at 08:10
  • Try to change your json....... Format also – Arjun saini Jul 22 '16 at 08:21
  • JSONArray objRootArray=new JSONObject("add your response").optJSONObject("data"); for (int i = 0; i < objRootArray.length(); i++) { try { if (objRootArray.getJSONArray(i)==null){ //this is your data array JSON Object }else { JSONArray objArray=objRootArray.getJSONArray(i);//This is your data inside JSON array inside JSON Array } } catch (JSONException e) { e.printStackTrace(); } } – Mahesh Kavathiya Jul 22 '16 at 08:33

0 Answers0