0

enter image description hereI have below response from an API How to parse the Json below using retrofit?

{
   "country1":{
            "id":"0",
            "name":"Jack"
   }, 

   "country2":{
            "id":"1",
            "name":"Rick"
   }

}

my data classes

data class Countries(@Expose var country: Map<String, Country>)
data class Country(var id: String, var name: String)
Pavlo Zin
  • 762
  • 6
  • 25

1 Answers1

0

Gson is generating the JSON like this -

data class Json4Kotlin_Base (

    @SerializedName("country1") val country1 : Country1,
    @SerializedName("country2") val country2 : Country2
)

Can use Jackson for hashmap mapping

Ravi
  • 2,277
  • 3
  • 22
  • 37