Stylianos Gakis
03/01/2024, 11:00 PM@Required
in order to ensure that during deserialization process, even if a class has a default value, the input still needs to have the field present.
Is there something for the opposite, where I got a class like
@Serializable
internal data class Foo(
val bar: String,
) {
val baz: String = "fixed_value"
}
and I do in fact want the serialization process for this for object Foo("someInput")
to serialize into this
{
"bar": "someInput",
"baz": "fixed_value"
}
Stylianos Gakis
03/01/2024, 11:03 PMencodeDefaults = true
on my JsonBuilder
would fix this, but that is a global setting which I am not sure I necessarily want to enforce in all other places as well.Stylianos Gakis
03/01/2024, 11:04 PM@kotlinx.serialization.EncodeDefault(mode = ALWAYS)
is what I want actually rubber duck