Chris Fillmore
12/18/2020, 3:02 PM1.0.0-RC
and updated to serialization-json 1.0.1
and it seems there is a change in behaviour for this use case:
@Serializable
class MyClass(
val id: String
) {
val message = "my message"
}
This is my serialization code:
val serializer = Json {
// Not relevant to the example but this is the Json serialization config I'm using
ignoreUnknownKeys = true
prettyPrint = true
}
val myClass = MyClass("abc123")
val serialized = serializer.serialize(myClass)
I expect serialized
to be
{
"id": "abc123",
"message": "my message"
}
but I’m getting
{
"id": "abc123"
}
Marc Knaup
12/18/2020, 3:06 PMSinceflag is now set toencodeDefaults
in the default configuration for JSON, CBOR and Protocol Buffers.false
message
defaults to "my message"
it’s not encoded unless you tell the serializer through your Json
config.Chris Fillmore
12/18/2020, 3:13 PMtrue
, but alas the source was cached and so out of dateChris Fillmore
12/18/2020, 3:13 PMencodeDefaults = true
and it works now. Thank you!