Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

No branches or pull requests

2 participants