Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Decode into map with case insensitive keys #306

Description

@andig

I have a situation where I don't know the target struct and hence decode into a map. This will create duplicate keys if input has multiple types of key case. It would be helpful if I could deduplicate the keys in a case insensitive way.

Activity

  1. mullerch commented on Oct 27, 2022

    @mullerch

    https://pkg.go.dev/github.com/mitchellh/mapstructure#DecoderConfig : MatchName

    // MatchName is the function used to match the map key to the struct
    // field name or tag. Defaults to `strings.EqualFold`. This can be used
    // to implement case-sensitive tag values, support snake casing, etc.
    MatchName func(mapKey, fieldName [string](https://pkg.go.dev/builtin#string)) [bool](https://pkg.go.dev/builtin#bool)
    
  2. andig commented on Oct 27, 2022

    @andig
    Author

    I don't think that applies here. This will match decoding into a struct, I'm decoding into a map?

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions