You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I consider this a bug. Null objects should be encoded as the simple type null, no matter whether they are class types or other types.
In our use case, this is causing issues after deserialization, since the empty map is deserialized into a default instance of the type, rather than null.
Please consider removing this line and always encoding as null.
The text was updated successfully, but these errors were encountered:
@Serializable
data classTest(valnullableClass:Inner?, valnullableMap:Map<String, String>?)
@Serializable
data classInner(valtest:Int)
val test =Test(nullableClass =null, nullableMap =null)
Cbor.encodeToByteArray(Test.serializer(), test)
// Hex output: bf6d6e756c6c61626c65436c617373a06b6e756c6c61626c654d6170f6ff
The hex output bf6d6e756c6c61626c65436c617373a06b6e756c6c61626c654d6170f6ff looks like this (from https://cbor.me/):
Traced to this line:
kotlinx.serialization/formats/cbor/commonMain/src/kotlinx/serialization/cbor/internal/Encoder.kt
Line 106 in d4d066d
I consider this a bug. Null objects should be encoded as the simple type
null
, no matter whether they are class types or other types.In our use case, this is causing issues after deserialization, since the empty map is deserialized into a default instance of the type, rather than
null
.Please consider removing this line and always encoding as
null
.The text was updated successfully, but these errors were encountered: