Skip to content

Instantly share code, notes, and snippets.

@nonylene
Created December 9, 2018 16:43
Show Gist options
  • Select an option

  • Save nonylene/475b3c1b2ab9efe01c2716f1f35ddfcd to your computer and use it in GitHub Desktop.

Select an option

Save nonylene/475b3c1b2ab9efe01c2716f1f35ddfcd to your computer and use it in GitHub Desktop.
minifier
import json
import sys
import os
def minify(file_name: str):
with open(file_name) as f:
j = json.load(f)
with open(file_name + ".json", 'w') as f:
json.dump(j, f, ensure_ascii=False)
os.remove(file_name)
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(description="Overwrite minify json")
parser.add_argument('files', metavar='FILE', type=str, nargs='+')
args = parser.parse_args()
for file_name in args.files:
minify(file_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment