title: Index 1 out of range [0..1) image
body: <p>i'm trying to get image from json and load it into xml. and i already get the image url and just have to load it. but whenever i try to load the image it always shows <code>Index 1 out of range [0..1)</code> error messege but i dont know why it happen.</p>
  
  <p>this is my code</p>
  
  <pre><code>val url = "https://www.thesportsdb.com/api/v1/json/1/lookupteam.php?id=133616"
      val request = Request.Builder().url(url).build()
      val client = OkHttpClient()
      client.newCall(request).enqueue(object : Callback, okhttp3.Callback {
          override fun onFailure(call: Call, e: IOException) {
              println("failed")
          }
  
          override fun onResponse(call: okhttp3.Call?, response: okhttp3.Response?) {
              val body = response?.body()?.string()
              println(body)
              val jsonObject = JSONObject(body)
              val jsonArray = jsonObject.getJSONArray("teams")
              for (i in 0..jsonArray.length()) {
                  val jsonObject2 = jsonArray.getJSONObject(i)
                  val lambang = jsonObject2.getString("strTeamBadge")
                  Log.v("lambang", "" + lambang)
                  Picasso.get().load(lambang).into(badge_away)
              }
          }
      })
  </code></pre>
  
  <p>and when i change the for to <code>while(i&lt;jsonArray.length()</code> it load the image over and over without stop.
  please if you know how to solve this please help</p>
  
  <p>ps: my jsonArray actually only have 1 index</p>