import json # 读取JSON文件内容 with open('./staticLogicEdgeInfo.json', 'r') as file: json_data = file.read() # 解析JSON内容 parsed_data = json.loads(json_data) # 将JSON内容转换为一行 compressed_json = json.dumps(parsed_data, separators=(',', ':')) # 将压缩后的内容写入文件 with open('staticLogicEdgeInfo.json', 'w') as file: file.write(compressed_json)