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
Describe the bug
Trying to serialize a object with enums fails with the following error:
SerializationException: Non-serializable class kotlin.Int is not supported by class com.ensarsarajcic.kotlinx.serialization.msgpack.internal.BasicMsgPackEncoder encoder
EnumSerializer from kotlinx-serialization-core-jvm is being used by default. Following it on the debugger, it all goes well until the last line of EnumSerializer.serialize:
overridefunserialize(encoder:Encoder, value:T) {
val index = values.indexOf(value)
if (index ==-1) {
throwSerializationException(
"$value is not a valid enum ${descriptor.serialName}, "+"must be one of ${values.contentToString()}"
)
}
encoder.encodeEnum(descriptor, index) //here
}
Where encoder is an instance of BasicMsgPackEncoder. I see that encodeEnum is not implemented in BasicMsgPackEncoder, so that could be part of the issue?
Expected behavior
The enum value should be serialized by its value's name (as the JSON serializer does), e.g. DRUID, KNIGHT, etc.
The same object can be serialized without problems using: Json.encodeToString.
The text was updated successfully, but these errors were encountered:
Version
Describe the bug
Trying to serialize a object with enums fails with the following error:
This is an example enum:
EnumSerializer
fromkotlinx-serialization-core-jvm
is being used by default. Following it on the debugger, it all goes well until the last line ofEnumSerializer.serialize
:Where
encoder
is an instance ofBasicMsgPackEncoder
. I see thatencodeEnum
is not implemented inBasicMsgPackEncoder
, so that could be part of the issue?Expected behavior
The enum value should be serialized by its value's name (as the JSON serializer does), e.g.
DRUID
,KNIGHT
, etc.The same object can be serialized without problems using:
Json.encodeToString
.The text was updated successfully, but these errors were encountered: