Skip to content

Questions about 'JsonStringEnumConverter' not using namingPolicy when deserializing the object. #41138

Closed

Description

@liui

Use the obtained string value directly here. But why not use _namingPolicy'?

like:

        internal override T ReadWithQuotes(ref Utf8JsonReader reader)
        {
            string? enumString = reader.GetString();
            
            var v =  _namingPolicy == null ? enumString : FormatEnumValueToString(enumString, encoder);
             
            // Try parsing case sensitive first
            if (!Enum.TryParse(v, out T value)
                && !Enum.TryParse(v, ignoreCase: true, out value))
            {
                ThrowHelper.ThrowJsonException();
            }

            return value;
        }

Activity

  1. added
    untriaged
    on Aug 21, 2020
  2. removed
    untriaged
    on Aug 26, 2020
  3. added this to the 5.0.0 milestone on Aug 26, 2020
  4. layomia commented on Aug 26, 2020

    @layomia
    Contributor

    Duplicate of #31619.

  5. ghost locked as resolved and limited conversation to collaborators on Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions