A JSON minify script written in Python.
source link: https://gist.github.com/KinoAR/a5cf8a207529ee643389c4462ebf13cd
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
A JSON minify script written in Python. · GitHub
Instantly share code, notes, and snippets.
#!/usr/bin/env python3 """JSON minify program. """
import json # import json library import sys # import sys library
def minify(file_name): "Minify JSON" file_data = open(file_name, "r", 1).read() # store file info in variable json_data = json.loads(file_data) # store in json structure json_string = json.dumps(json_data, separators=(',', ":")) # Compact JSON structure file_name = str(file_name).replace(".json", "") # remove .json from end of file_name string new_file_name = "{0}_minify.json".format(file_name) open(new_file_name, "w+", 1).write(json_string) # open and write json_string to file
ARGS = sys.argv[1:] # get arguments passed to command line excluding first arg for arg in ARGS: # loop through arguments minify(arg)
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK