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

JsonStringEnumMemberConverterOptionsAttribute & custom naming policy is not working together #31

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

Comments

@ShirlyAr
Copy link

ShirlyAr commented Oct 12, 2022

Hi,
I've tried the combination of

`[JsonStringEnumMemberConverterOptions(deserializationFailureFallbackValue: MyEnum.Unknown)]
[JsonConverter(typeof(JsonStringEnumMemberConverter))]
public enum MyEnum
{
Unknown = 0,

[EnumMember(Value = "value1")]
ValidValue = 1

}`
When I use the following custom policy name :

public void ConfigureServices(IServiceCollection services) { services.AddControllers() .AddJsonOptions(options => { options.JsonSerializerOptions.Converters.Add(new JsonStringEnumMemberConverter(new UpperSnakeCaseNamingPolicy(), false)); options.JsonSerializerOptions.WriteIndented = true; });

Issues observed:

  1. once the fallback attribute is added converter is not working on serialize/deserialize
  2. fallback value is not being handled

Am I missing something in my implementation?

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