-
Notifications
You must be signed in to change notification settings - Fork 167
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
Could not bind to enums when using Newtonsoft.Json #2289
Comments
@Zoe1808 can you share how you're configuring the serializer? Sharing the program.cs file should help |
Hi @liliankasem
We also tried to add the converter, but did not work.
|
it looks like we don't have an Enum converter so I do not expect this to work. As for using Newtonsoft/System.Text - I don't think they support plain Enum deserialization, it would need to be part of a POCO. I.e. public class Item
{
EnumType Type { get; set; }
} If you do want it to work exactly with an Enum binding, you could write your own converter and register it. We don't have any official docs for that but this blog post outlines the steps for this: |
Here is a sample app with a custom converter implementation which binds to the enum. https://github.com/kshyju/MoreDotnetIsolatedSamples/tree/master/EnumInputConverter |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If you are not the original author (Zoe1808) and believe this issue is not stale, please comment with |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. |
Description
We've set the serializer to newtonsoft.Json, and got below exceptions when binding to an enum:
For TypeEnum, I've added a json converter.
Steps to reproduce
see description.
The text was updated successfully, but these errors were encountered: