Bobby Hargett
09/19/2024, 7:45 PMimport com.google.gson.annotations.SerializedName
import kotlinx.serialization.SerialName
enum class Size(private val value: String) {
@SerialName("S")
SMALL("S"),
@SerialName("M")
MEDIUM("M"),
@SerialName("L")
LARGE("L"),
@SerialName("XL")
XLARGE("XL");
override fun toString(): String = value
}
but then I get this error:
kotlinx.serialization. SerializationException: com..... model. Size does not contain element with name 'XL' and the json looks like this:
"size": "XL",
So do I really need to read a custom serializer for each enum?Stylianos Gakis
09/19/2024, 9:55 PMBobby Hargett
09/20/2024, 12:01 PMStylianos Gakis
09/20/2024, 12:29 PM