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

Add support for numeric json class discriminators #2142

Open
JesseCorbett opened this issue Dec 29, 2022 · 2 comments
Open

Add support for numeric json class discriminators #2142

JesseCorbett opened this issue Dec 29, 2022 · 2 comments

Comments

@JesseCorbett
Copy link

What is your use-case and why do you need this feature?

Many APIs such as Discord use type codes, which align very closely to this library's JsonClassDiscriminator feature. However, these type codes are frequently numeric instead of strings, which makes them incompatible with this library without complex workarounds.

Describe the solution you'd like

I would prefer a solution which adds an option to specify the serialized type of a discriminator, such as an addition annotation parameter as an enum of supported types, defaulting to string

@sandwwraith
Copy link
Member

So the actual problem is that you can't use discriminators like {"type": 123}, without the quotes?

@JesseCorbett
Copy link
Author

That is essentially the problem, yes

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

No branches or pull requests

2 participants