Created
September 9, 2022 15:09
-
-
Save turicas/e01aa6595c66a1e7206ef749f4b50d07 to your computer and use it in GitHub Desktop.
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
import argparse | |
import json | |
def prettify(filename, indent=2, output_filename=None): | |
with open(filename) as fobj: | |
data = json.load(fobj) | |
with open(output_filename or filename, mode="w") as fobj: | |
json.dump(data, fobj, indent=indent) | |
if __name__ == "__main__": | |
parser = argparser.ArgumentParser() | |
parser.add_argument("input_filename") | |
parser.add_argument("--output-filename") | |
parser.add_argument("--indent", default=2) | |
args = parser.parse_args() | |
prettify(filename, indent=args.indent, output_filename=args.output_filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment