-
Notifications
You must be signed in to change notification settings - Fork 637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrapping SealedClassSerializer yields wrong serialization results #2838
Comments
The "wrong" result
but why....? |
It's probably checks like these (below) that make this impossible to wrap
|
Also, opened #2839 -- most likely that issue is also due to JsonEncoder taking bad shortcuts |
One of the issues at the least is that the descriptors need to have a context (through calling |
Try rewriting your wrapper as override fun deserialize(decoder: Decoder): T = decoder.decodeSerializableValue(sealedSerializer)
override fun serialize(encoder: Encoder, value: T) {
encoder.encodeSerializableValue(sealedSerializer, value)
}
|
With serialization 1.7.3:
Serializing
SealedDataClass
returns{"type":"SealedDataClass"}
as expected:However, if I simply wrap the default serializer like this:
The result is completely different (and wrong) --
["SealedDataClass",{}]
:This is puzzling, because with the default serializer, debugger (Android Studio Koala) skips over
encodeToString
even if I try to step in -- but with a wrapped serializer, I can actually debug by stepping through normally.What's going on?
P.S. I'm trying to wrap
SealedClassSerializer
so I can handle deserialization exceptions better.The text was updated successfully, but these errors were encountered: