title: Android: How to parse nested json array with different data type objects using retrofit - moshi?
body: <p>I want to parse nested json using retrofit moshi. The json data i'm having is an array, inside array first element is string &amp; second is again an array.</p>
  <p>I don't want to parse first element in the array (<code>&quot;list&quot;</code>), just want to parse second element from the array (i.e. Inner array).
  But i'm facing challenges exactly here with the data object to be use.</p>
  <p>Obviously we can use <code>Any</code> type in kotlin with list, but again will loose type of the object inside the list.</p>
  <p>Json Format:</p>
  <pre><code>{
    &quot;results&quot;: [
      &quot;list&quot;,
      [
        {
          //jsonobj
        },
        {
          //jsonobj
        }
      ]
    ]
  }
  </code></pre>
  <p>I want to parse json with this Data class that i have created without parsing first element &amp; parse directly second element.</p>
  <pre><code>@JsonClass(generateAdapter = true)
      data class ResponseModel(
          @Json(name = &quot;results&quot;)
          val results: List&lt;Results?&gt;?,
      ) {
          @JsonClass(generateAdapter = true)
          data class Results(
              @Json(name = &quot;reference&quot;)
              val reference: String?,
              @Json(name = &quot;enabled&quot;)
              val enabled: Boolean,
          )
      }
  </code></pre>
  <p>fromJson overridden function</p>
  <pre><code>@Throws(IOException::class)
      override fun fromJson(reader: JsonReader): C {
          val result = newCollection()
          reader.beginArray()
          while (reader.hasNext()) {
              result?.add(elementAdapter.fromJson(reader)!!)
          }
          reader.endArray()
          return result
      }
  </code></pre>
  <p>This is throwing an exception saying <code>EXPECTED_OBJECT but it was STRING</code> when trying to parse first element (<code>&quot;list&quot;</code>).
  i'm stuck here &amp; not able to proceed further.</p>
  <p>So can somebody plz help me to get out from here? any help will be appreciated.</p>