Created
March 2, 2014 05:41
-
-
Save michaelBenin/9302474 to your computer and use it in GitHub Desktop.
Alphabetize your json file
This file contains 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
# python alphabetize-json test.json | |
import json | |
import sys | |
args = sys.argv[1:] | |
for json_file in args: | |
with open(json_file, 'r') as file: | |
alphabetized = json.loads(file.read()) | |
with open(json_file, 'w') as w: | |
w.write(json.dumps(alphabetized, separators=(',', ': '), indent=2, sort_keys=True)) | |
w.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI ^ didn't cut it for me.