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

suggestion: backward compatibility to deserialize same enum type option to itself #32

Open
ShirlyAr opened this issue Oct 12, 2022 · 0 comments

Comments

@ShirlyAr
Copy link

ShirlyAr commented Oct 12, 2022

In case of using a custom converter policy for example:
options.Converters.Add(new JsonStringEnumMemberConverter(new UpperSnakeCaseNamingPolicy(), false));

 class public enum Days
{
   SundayDay,
   MondayDay,
   FridayDay
}

In POST action , when trying to deserialize "SUNDAY_DAY " the input can be :

  • "Sunday_Day"
  • "SUnday_DAY"
  • "sunday_day"
    the result of deserialize will be correct -> Days.SundayDay

We might want to support backward compatibility to deserialize same enum type option to itself.
So in POST action , when trying to deserialize "SundayDay " to -> Days.SundayDay it will work.

Adding this line of code, will accomplish that:

_TransformedToRaw[typedValue.ToString()] = new EnumInfo(name, typedValue, rawValue);

Please consider adding this capability to the code.
Thanks!

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

No branches or pull requests

1 participant