Skip to content

Instantly share code, notes, and snippets.

@theresama
Created February 25, 2018 02:37
Show Gist options
  • Save theresama/177c1f0e39bf2aebc82ce8b5fcb4cb57 to your computer and use it in GitHub Desktop.
Save theresama/177c1f0e39bf2aebc82ce8b5fcb4cb57 to your computer and use it in GitHub Desktop.
import argparse
import collections
import json
def main(argv=None):
parser = argparse.ArgumentParser()
parser.add_argument('json_file')
args = parser.parse_args(argv)
with open(args.json_file, 'r') as f:
ugly_json = json.load(f, object_pairs_hook=collections.OrderedDict)
with open(args.json_file, 'w') as w:
json.dump(ugly_json, w, indent=2)
if __name__ == "__main__":
exit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment