Nmrsmn
01/10/2024, 1:26 PMJson {}
configuration the serialisation of the following class results in only a type
and is missing the state
value..
@Serializable
data object Toggle : StateAction {
@EncodeDefault(EncodeDefault.Mode.ALWAYS)
override val state: State = State.TOGGLE
}
If I change it to an data class with the state having the same default value it works..
What is this kind of mechanic and how to make sure it is working?Adam S
01/10/2024, 7:32 PMval serializer = Toggle.serializer()
val elementNames = serializer.descriptor.elementDescriptors.joinToString { it.serialName }
println("elementNames: $elementNames")
Perhaps the generated descriptor should check the properties of an object
, to see if there are @EncodeDefault
fields? Have you looked on the GitHub issue board to see if there's a similar issue?
You could hand write a serializer, but the easiest option would be to just make Toggle
a class!Nmrsmn
01/10/2024, 10:57 PM