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

Decode into map with case insensitive keys #306

Open
andig opened this issue Sep 17, 2022 · 2 comments
Open

Decode into map with case insensitive keys #306

andig opened this issue Sep 17, 2022 · 2 comments

Comments

@andig
Copy link

andig commented Sep 17, 2022

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.

@mullerch
Copy link

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)

@andig
Copy link
Author

andig commented Oct 27, 2022

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants