Created
August 31, 2017 15:49
-
-
Save codeadict/13e8cfbb2e720145e31a96fc2f63aae1 to your computer and use it in GitHub Desktop.
Lower case Json decoder in Python3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class LowerCaseJSONDecoder(JSONDecoder): | |
| def _lower_keys(self, obj): | |
| new = {} | |
| for k, v in obj.items(): | |
| if isinstance(v, dict): | |
| v = self._lower_keys(v) | |
| new[k.lower()] = v | |
| return new | |
| def decode(self, *args, **kwargs): | |
| obj = super().decode(*args, **kwargs) | |
| return self._lower_keys(obj) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: