Is it true that Kotlinx Serialization leaves a val...
# serialization
d
Is it true that Kotlinx Serialization leaves a value out of json if it == it's default value?
Like:
Copy code
data class Foo(val name: String, val bl: Boolean = true)
val foo = Foo("bar", true)
// Becomes:
// { "name": "bar" } not { "name": "bar", "bl": true }?
a
yes
Default values are not encoded by default in JSON. This behavior is motivated by the fact that in most real-life scenarios such configuration reduces visual clutter, and saves the amount of data being serialized.
https://github.com/Kotlin/kotlinx.serialization/blob/v1.5.0/docs/basic-serialization.md#defaults-are-not-encoded-by-default
d
A bit unexpected though... Especially since on client side, the default was the opposite...