KR
10/18/2024, 8:04 AMjson(Json {
prettyPrint = true
isLenient = true
encodeDefaults = true
ignoreUnknownKeys = true
useAlternativeNames = true
coerceInputValues = true
explicitNulls = false
})
this is my config
despite having encodeDefaults = true
I am unable to encode default values of data class to Json
Am I doing something wrong here or is this an existing issue?glureau
10/18/2024, 8:41 AMKR
10/18/2024, 9:56 AMnulls and when keys are missing while decoding default values are set.glureau
10/18/2024, 2:31 PMval foo: String? = null => encode or not ??). Maybe one settings is changing the other.KR
10/19/2024, 8:09 AMencodeDefaults = true & explicitNulls = false
by the naming convention it should do the expected but it doesn’tNikky
10/24/2024, 5:18 AMKR
10/24/2024, 5:18 AMNikky
10/24/2024, 2:00 PM@Serializable
data class A(
val a: String? = null,
val b: Int = 0,
)
serializing this data class with default values ... and the settings you are using
a gets skipped because it ends up being null and b gets serialized
https://pl.kotl.in/-YkdiyRIdKR
10/25/2024, 5:49 AM