Skip to content
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

Kotlin serialization custom discriminator name #343

Conversation

ulrikandersen
Copy link
Collaborator

@ulrikandersen ulrikandersen commented Dec 20, 2024

This PR adds support for polymorphic discriminators with names other than "type", which is the default class discriminator used by Kotlin serialization.

Non-default class disciminators are defined using the JsonClassDiscriminator annotation (docs) and requires opt-in by the user.

@ulrikandersen ulrikandersen self-assigned this Dec 20, 2024
@cjbooms cjbooms marked this pull request as ready for review December 20, 2024 09:55
@cjbooms cjbooms marked this pull request as draft December 20, 2024 09:55
@cjbooms cjbooms marked this pull request as ready for review December 20, 2024 10:09
Copy link
Owner

@cjbooms cjbooms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice work.

Feel free to merge when you like and I can cut a final release for 2024

Kotlin Serialization by default uses `type` for the JSON class discriminator property and thus we need to specify the property name explicitly when it is not `type`.

Note that `JsonClassDiscriminator` is part of the experimental serialization API and requires opt-in from the user.
@ulrikandersen ulrikandersen force-pushed the kotlin-serialization-custom-discriminator-name branch from cd2c6e4 to e9be32a Compare December 20, 2024 11:51
@ulrikandersen ulrikandersen merged commit 3de202c into cjbooms:master Dec 20, 2024
1 check passed
@ulrikandersen ulrikandersen deleted the kotlin-serialization-custom-discriminator-name branch December 20, 2024 11:54
@ulrikandersen
Copy link
Collaborator Author

LGTM. Nice work.

Feel free to merge when you like and I can cut a final release for 2024

Thanks 🙏 What a way to end the year 🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants