Run with
find . -type f -name '*.json' | xargs -n 1 python convert_json_to_msgpack.py
| import fileinput | |
| import msgpack | |
| import sys | |
| import json | |
| file_lines = [] | |
| args = sys.argv[1] | |
| for line in fileinput.input(args): | |
| file_lines.append(line) | |
| file_content = ''.join(file_lines) | |
| file_dict = json.loads(file_content) | |
| packed = msgpack.packb(file_dict) | |
| output_file = args.replace('json', 'pack') | |
| with open(output_file, 'w') as fw: | |
| fw.write(packed) | |
| exit(1) |