Created
March 16, 2020 14:35
-
-
Save trolologuy/30ac975ac1305f8c3d6ab1a0c72af825 to your computer and use it in GitHub Desktop.
Simple python script to unminify JSON
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
#!/usr/bin/python | |
import json | |
import argparse | |
def read_json(args): | |
"Reads and unminifies the JSON input" | |
with open(args.filename) as json_data: | |
data = json.load(json_data) | |
data_unminified = json.dumps(data, indent=4) | |
print(data_unminified) | |
def main(): | |
"""Console script for unminifying json files.""" | |
# create the top-level parser | |
parser = argparse.ArgumentParser() | |
# All extraction arguments | |
parser.add_argument('filename') | |
args = parser.parse_args() | |
read_json(args) | |
return 0 | |
if __name__ == "__main__": | |
# Disable all the no-value-for-parameter violations in this function | |
# pylint: disable=no-value-for-parameter | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment