Question: The data that I want to use has this structure:

```
{
    "1": {
        "id": 1,
        "name": "Bulbasaur"
    },
    "2": {
        "id": 2,
        "name": "Ivysaur"
    },
    "3": {
        "id": 3,
        "name": "Venusaur"
    }
}

```

**Note:**
The number labeling each object matches the id of the Pokémon, not the number of Pokémon

My problem is that when I try to create data classes for this it ends up creating a data class for each object. Not one data class that fits each object. I believe this is due to the number labeling the object(Pokémon) being different for each object.

Is there a way I can format this data in maybe one or two data classes and not over 800?

Ideally I would like the data to be structured like this but it does not work when run.

```
data class ReleasedPokemonModel(
    val id: Int,
    val name: String
)

```

Answer: 
When parsing Json to Object with this special case, you should custom Json Deserializer yourself.

Here I use Gson library to parse Json to Object.

First, create a custom Json Deserializer with Gson. As follows:

*PokemonResponse.kt*

```
data class PokemonResponse(
    val pokemonMap: List<StringReleasedPokemonModel>
)

data class ReleasedPokemonModel(
    val id: Int,
    val name: String
)

```

*GsonHelper.kt*

```
object GsonHelper {
    fun create(): Gson = GsonBuilder().apply {
        registerTypeAdapter(PokemonResponse::class.java, PokemonType())
        setLenient()
    }.create()

    private class PokemonType : JsonDeserializer<PokemonResponse> {
        override fun deserialize(
            json: JsonElement?,
            typeOfT: Type?,
            context: JsonDeserializationContext?
        ): PokemonResponse {
            val list = mutableListOf<ReleasedPokemonModel>()
            // Get your all key
            val keys = json?.asJsonObject?.keySet()
            keys?.forEach { key ->
                // Get your item with key
                val item = Gson().fromJson<ReleasedPokemonModel>(
                    json.asJsonObject[key],
                    object : TypeToken<ReleasedPokemonModel>() {}.type
                )
                list.add(item)
            }
            return PokemonResponse(list)
        }
    }
}

```

Next I will create a `GsonConverterFactory` so that I can `addConvertFactory` to Retrofit.

```
val gsonConverterFactory = GsonConverterFactory.create(GsonHelper.create())

```

And now I will add retrofit.

```
val retrofit = Retrofit.Builder()
    // Custom your Retrofit
    .addConverterFactory(gsonConverterFactory) // Add GsonConverterFactoty
    .build()

```

Finally in ApiService, your response will now return type `PokemonResponse`.

```
interface ApiService {
    @GET("your_link")
    suspend fun getGenres(): PokemonResponse
}

```
The problem is that there's no JSON array there. it's literally one JSON object with each Pokemon listed as a property. I would recommend that you reformat the JSON beforehand to look like this:

```
[
    {
        "id": 1,
        "name": "Bulbasaur"
    },
    {
        "id": 2,
        "name": "Ivysaur"
    },
    {
        "id": 3,
        "name": "Venusaur"
    }
]

```

And then you could model it like this:

```
data class ReleasedPokemonModel(
    val id: Int,
    val name: String
)

data class Response(
    val items: List<ReleasedPokemonModel>
)

```

[See more here.](https://stackoverflow.com/a/45541563/7434090)

[And see here for discussion about reformatting the data before handing it to Retrofit.](https://stackoverflow.com/questions/49490230/use-gson-retrofit-on-serializedname-which-is-unknown-beforehand/49501210)