-
Notifications
You must be signed in to change notification settings - Fork 620
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
Don't check kind if needn't type discriminator for enum and primitive #2753
Comments
Can you post an example code and incorrect output, please? |
The same error with #1486. |
You always need type information when deserializing polymorphic type. Are you talking about serialization-only use case? |
https://github.com/Kotlin/kotlinx.serialization/blob/master/formats/json/commonMain/src/kotlinx/serialization/json/JsonConfiguration.kt#L78-L84 said it's a use case. |
What is your use-case and why do you need this feature?
Output the enum and primitive correctly.
If we add a PrimitiveKind descriptor to a subclass of polymorphic serializer. There is error #1486
If we add a wrapper for the primitive(#1252 (comment)). The result will be wrapped even if the
classDiscriminatorMode = ClassDiscriminatorMode.NONE
like below.Related: #1252 #1486
Describe the solution you'd like
https://github.com/Kotlin/kotlinx.serialization/blob/master/formats/json/commonMain/src/kotlinx/serialization/json/internal/Polymorphic.kt#L41
Avoid failing if needn't discriminator for
checkKind
. Add a condition incheckKind
orencodePolymorphically
The text was updated successfully, but these errors were encountered: