Skip to content

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

@loutPhilipps

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

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