Search code examples
androidkotlinretrofit2

Parse json map in Retrofit


I have web service that returns json response like this

"map": [
        [
            0,
            "A mother of our mother"
        ],
        [
            2,
            "A brother of our father"
        ],
        [
            1,
            "A daughter of our sister"
        ]
    ],

How do i define data class to handle this response?

data class Map(
   @SerializedName("map")
   val map : <What type/class definition here>

)

Solution

  • This JSON represent array of objects array.

    data class Map(
      @SerializedName("map")
      val map : List<List<Any?>>
    )