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

Add configuration for forcing case-sensitive key/tag matches in decoding. #81

Closed
wants to merge 1 commit into from

Conversation

gavbaa
Copy link

@gavbaa gavbaa commented May 18, 2017

This pull request proposes adding a new configuration option: CaseSensitiveKeys. If true, this would only allow for exact matches on struct Field/Tag names, whereas if false it would use the current behavior of doing Unicode code-folding on the key maps.

Example use case: The Experience API standard (xAPI, detailed here: https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#lrs-requirements ), which is defined on top of JSON, requires that "The LRS MUST reject Statements...where the case of a key does not match the case specified in this specification." Someone bringing in the JSON data and wanting to use mapstructure to copy it into appropriately defined structs has to be sure that the "id" key is "id" and not "ID" in order to validate within the specification.

Good test coverage included in pull request.

There's also a tiny performance perk by not having to iterate the map! :)

@abemedia
Copy link
Contributor

@mitchellh this can probably be closed now since #250 is merged.

@mitchellh
Copy link
Owner

Good call thanks!

@mitchellh mitchellh closed this Sep 14, 2021
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

Successfully merging this pull request may close these issues.

None yet

3 participants