(file_path)
| 19 | |
| 20 | |
| 21 | def reformat_json_file(file_path): |
| 22 | with open(file_path, 'r', encoding='utf-8') as f: |
| 23 | content = f.read() |
| 24 | |
| 25 | data = json.loads(content) |
| 26 | formatted_content = json.dumps(data, indent=2, separators=(',', ': '), ensure_ascii=False) |
| 27 | |
| 28 | with open(file_path, 'w', encoding='utf-8') as f: |
| 29 | f.write(formatted_content) |
| 30 | f.write('\n') |
| 31 | |
| 32 | |
| 33 | if __name__ == '__main__': |