title: Android Kotlin parsing nested JSON
body: <p>I'm still pretty new to programming with Kotlin but I can't seem to figure out the correct way to parse my JSON. I'm attempting to get "title" and "body" from "notification" in "unackd" array only. </p>
  
  <p>So far I've got: </p>
  
  <pre><code>private fun parse(): Boolean {
      try {
          val ja = JSONArray(jsonData)
          var jo: JSONObject
  
          users.clear()
          var user: User
  
          for (i in 0 until ja.length()) {
              jo = ja.getJSONObject(i)
  
              val name = jo.getString("title")
              val username = jo.getString("body")
  
              user = User(username,name)
              users.add(user)
          }
  
          return true
      } catch (e: JSONException) {
          e.printStackTrace()
          return false
      }
  }
  </code></pre>
  
  <p>Meanwhile my JSON is structured as so:</p>
  
  <pre><code>{
  "unackd": [
      {
          "notification": {
              "title": "Title Test Number 200",
              "body": "passage local they water difficulty tank industry allow increase itself captured strike immediately type phrase driver change save potatoes stems addition behavior grain trap rapidly love refused way television bright 1100"
          },
          "data": {
              "id": "1100",
              "phone": "+15555551234"
          }
      },
      {
          "notification": {
              "title": "Title Test Number 199",
              "body": "announced beside well noted mysterious farm he essential likely deeply vast touch 1099"
          },
          "data": {
              "id": "1099",
              "phone": "+15555551234"
          }
      }
  ],
  "ackd": [
     {
          "notification": {
              "title": "Title Test Number 200",
              "body": "passage local they water difficulty tank industry allow increase itself captured strike immediately type phrase driver change save potatoes stems addition behavior grain trap rapidly love refused way television bright 1100"
          },
          "data": {
              "id": "1100",
              "phone": "+15555551234"
          }
      },
      {
          "notification": {
              "title": "Title Test Number 199",
              "body": "announced beside well noted mysterious farm he essential likely deeply vast touch 1099"
          },
          "data": {
              "id": "1099",
              "phone": "+15555551234"
          }
      }
  ]
  }
  </code></pre>
  
  <p>I believe my issue is getting into "notification" to then get the strings "title" and "body". Which I've tried </p>
  
  <pre><code>test1 = jo.getJSONObject("notification")
  </code></pre>
  
  <p>Any help would be appreciated!</p>
  
  <p>EDIT:</p>
  
  <p>This is my logcat error, I assume it has to do with the JSON.typeMismatch:</p>
  
  <pre><code>at org.json.JSON.typeMismatch(JSON.java:111)
  at org.json.JSONArray.&lt;init&gt;(JSONArray.java:96)
  at org.json.JSONArray.&lt;init&gt;(JSONArray.java:108)
  at android.os.AsyncTask$2.call(AsyncTask.java:333)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
  at java.lang.Thread.run(Thread.java:764)
  </code></pre>