首页 > 解决方案 > 用于文件节拍的 json EOL

问题描述

通过python脚本从api中转储一些json数据,并保存到文件中,需要将这些数据推送到elasticsearch。Filebeat 需要 EOL 来解析 json 数据。

我们如何通过python将EOL添加到json?

保存文件使用 json.dump

with open('/tmp/file.log', 'w') as f:
             json.dump(incident, f)

标签: pythonjson

解决方案


推荐阅读