Skip to content

JsonStringEnumMemberConverterOptionsAttribute & custom naming policy is not working together #31

@ShirlyAr

Description

@ShirlyAr

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions