Mohammed Akram Hussain
10/04/2023, 4:42 PM@SerialName
with @SerialisedName
from gson for the enum values.
Also, it works when I change the enum name to all lower case which matches the response value. Any ideas what I'm doing wrong?
@Serializable
data class Colours(
@SerialName("palette")
val palette: Palette,
@SerialName("theme")
val theme: ColoursTheme = ColoursTheme.White
)
@Serializable
enum class ColoursTheme {
@SerialName("white")
White,
@SerialName("bold")
Bold,
@SerialName("black")
Black,
@SerialName("accent")
Accent
}
This is the JSON:
{
"colours": {
"theme": "accent",
"palette": {
"primaryHex": "#537e66",
"secondaryHex": "#f3f3eb",
"accentHex": "#537e66"
}
},
}
Chris Fillmore
10/04/2023, 4:58 PMval theme: ColoursTheme
is not nullableMohammed Akram Hussain
10/04/2023, 4:59 PMColours(palette = paletterObj, theme = null)
which is strange.