-
Notifications
You must be signed in to change notification settings - Fork 50
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
Content-based polymorphism #612
Comments
Would what has been proposed in #607 be suitable for your use case? |
Yes, that seems sufficient. |
2 tasks
I'm as well in need of a JsonContentPolymorphicSerializer equivalent. @charleskorn could you please find the time to move forward with the review of the related PRs by @Jojo4GH? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the problem you'd like to solve
I have a YAML configuration that contains values which can be strings or objects such as:
I couldn't find any way to deserialize this into something like
MonolingualString
orMultilingualString
depending on the structure (more specifics at https://stackoverflow.com/q/78966200/5740428). I would have to specify the type in a!<type>
ortype:
tag, and that's unnecessary.Besides this use case, one could easily imagine providing RGB colors either as
"#ff0000"
hex code strings or{ r: 255, g: 0, b: 0 }
objects.Describe the solution you'd like
Something similar to https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/json.md#content-based-polymorphic-deserialization, i.e. content-based polymorphism.
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: