Skip to content

[bug] Mapstructure handles fields with different case twice #75

Open

Description

@loutPhilipps

In encoding/json:

Unmarshal matches incoming object keys to the keys used by Marshal (either the struct field name or its tag), preferring an exact match but also accepting a case-insensitive match

We can confirm this behavior (see playground): if our struct defines a tag with a different case, it will fall back to it, but if there are 2 fields, 1 with the right, 1 with the wrong case, it will select the correct one.

Image

However, in this specific case, mapstructure handles things differently (see playground): the field is present twice, with both the case-correct and case-incorrect values.

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions