title: unable to convert json array to json list
body: <p>Graph api returning json array data here is it's detail <img src="https://i.stack.imgur.com/MM9FO.png" alt="image contains the  list of json array"> </p>
  
  <p>I had a Task to display these json array to my recyclerView so i tried  to convert json array  to a arraylist  but my array List Returning 0 . 
  i am not getting what probable changes needed for the correct parsing here is my detail code </p>
  
  <pre><code>                GraphRequest(
                  AccessToken.getCurrentAccessToken(), "/me/posts", null,HttpMethod.GET,
                  GraphRequest.Callback { response -&gt;
                      Log.e(TAG, response.toString())
  
                      try {
  
  
                          var json: JSONObject = response.jsonObject
                          var jarray: JSONArray = json.getJSONArray("data")
  
                              mArrayList = ArrayList()
  
  
  
                              for (i in 0 until jarray.length()) {
  
                                 // mArrayList = ArrayList()
                                  var mdataa: JSONObject = jarray.getJSONObject(i)
  
                                  if (mdataa == null) {
                                      Toast.makeText(this, " Nothing here", Toast.LENGTH_SHORT).show()
                                  }
                                  // this part don't have any mistake
  
  
                                  mMessage = mdataa.getString("message")
                                  mId = mdataa.getString("id")
                                  mCreatedTime = mdataa.getString("created_time")
                                  this.mArrayList?.add(Data(mMessage, mId, mCreatedTime))
  
                              }
  
  
  
  
                      } catch (e: JSONException) {
  
                          e.printStackTrace()
                      }
                      Toast.makeText(this,"total number of values in arraylist" + mArrayList?.size ,Toast.LENGTH_LONG).show() // this toast returning 0 value
  
  
  
                      if (mArrayList == null) {
                          Toast.makeText(this, "U GET Nothing here", Toast.LENGTH_SHORT).show()
                      } else {
  
  
                          var main: Intent = Intent(this@Display, DisplayingPost::class.java)
  
                          main.putParcelableArrayListExtra("data", mArrayList)
                          startActivity(main)
  
  
                      }
                  }
  
          ).executeAsync()
  </code></pre>
  
  <p>updated: i tried this still it's returning null
              try {</p>
  
  <pre><code>                        var jsonResponse:JSONObject= JSONObject(response.toString())
                          var jsonArray:JSONArray=jsonResponse.getJSONArray("data")
  
                          for (i in 0 until jsonArray.length())
                          {
                              var insidata:JSONObject=jsonArray.getJSONObject(i)
                              var mMessage:String=insidata.getString("message")
                              allMessage?.add(mMessage)
                              var mId:String=insidata.getString("id")
                              allId?.add(mId)
                              var dateofCreation:String=insidata.getString("created_time")
                              allCreatedDate?.add("dateofCreation")
  
                          }
  
  
                      }
  
                      catch (e: JSONException)
                      {
                          e.printStackTrace()
                      }
                      Toast.makeText(this,"Size here is"+ allId?.size ,Toast.LENGTH_LONG).show()
  
                  }
  
          ).executeAsync() 
  </code></pre>
  
  <p>For Now I removed try catch block  and changed few line of code which resulted in a Toast message that was Displaying my JSONArray size which was 25 but when i tired to  fetch each object inside for block and displayed a Toast for value Outside of "for" block it is  Still Returning null  here is my new line of code .</p>
  
  <pre><code>                           //  try {
  
  
                          var jsonResponse:JSONObject=  response.getJSONObject()
                      // JSONObject(response.toString())
                          var jsonArray:JSONArray=jsonResponse.getJSONArray("data")
                    //  Toast.makeText(this,"Size here is"+ jsonArray.length() ,Toast.LENGTH_LONG).show()
  
                          for (i in 0 until jsonArray.length())
                          {
                              var insidata:JSONObject=jsonArray.getJSONObject(i)
                              if (insidata.has("message")) {
                                  var mMessage: String? = insidata.getString("message")
                                  allMessage?.add(mMessage as String)
                              }
  
                              var mId:String=insidata.getString("id")
                              allId?.add(mId)
                              var dateOfCreation:String=insidata.getString("created_time")
                              allCreatedDate?.add(dateOfCreation)
  
                          }
  
  
                    //  }
  
                   //   catch (e: JSONException)
                    //  {
                      //    e.printStackTrace()
                     // }
                      Toast.makeText(this,"Size here is"+ allMessage?.size ,Toast.LENGTH_LONG).show()
  
                  }
  
          ).executeAsync()
  </code></pre>
  
  <p>for now what i did i implimented a Toast message inside my for loop which returning the 1st Object of json Array</p>
  
  <pre><code>               }
                              if (i==0) {
                                  Toast.makeText(this, "" + insidata, Toast.LENGTH_LONG).show()
                              }
  </code></pre>
  
  <p>but when i implimented this</p>
  
  <pre><code>          }
                              if (i==0) {
                                  Toast.makeText(this, "" + mId, Toast.LENGTH_LONG).show()
  </code></pre>
  
  <p>i don't undERsTAND WHY IT IS  Still RETURNING NULL
  plz help me get out of it
                                  }</p>