And how can I make optional deletaged properties ?
I'm coupling serialization with Compose and I have a
val state by mutableStateOf(MyEnum.FIRST_VALUE)
, I want to omit the field if it is equal to
MyEnum.FIRST_VALUE
as it is the default one and most used through my code, but I don't understand how 🤔
I have a custom Serialiazer and I'm encoding the value as Nullable and I've set
encodeDefaults = false
in my Json configuration, but it's still emitted and when I try to read the JSON I get this
Exception in thread "AWT-EventQueue-0" kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 8: Expected numeric literal
JSON input: [{"task":"test #1","state":null},{"task":"test #2","state":null}]