# android

Ahren Swett

07/12/2022, 5:49 PM
Help with kotlin Serialization deserializing deep JSON elements. in the element below I am trying to get the sprites: other: official-artwork: but I’m having a really tough time figuring it out I’m not sure how to interact with the dash in the middle of the name I believe the underscore in the front_default will parse nicely but any help appreciated
Copy code
  "name": "bulbasaur",
  "id": 1,
  "sprites": {
    "back_default": "String",
    "front_default": "String",
    "front_female": null,
    "other": {
      "dream_world": {
        "front_default": "String",
        "front_female": null
      "official-artwork": {
        "front_default": "String"
I have data classes defined as this
Copy code
val pokemonFormat = Json {
    ignoreUnknownKeys = true
    coerceInputValues = true
    explicitNulls = false
    isLenient = true }

data class Pokemon(
    val name : String?,
    val types : List<Type>,
    val Stats: List<Stat>?,
    val order : Int?,

    //not sure how to use Kotlin Serialization to get this
    val sprites: Map<String, ?????>
data class Type(
   val type: Map<String,String>

data class Stat(
    val stat: Map<String,String>

data class Other(
 val other: Map<String,String>

Tower Guidev2

07/13/2022, 7:54 AM
does this help?