在我的Unix shell脚本中,当我执行curl命令时,结果将显示如下,我将重定向到文件:
{"type":"Show","id":"123","title":"name","description":"Funny","channelTitle":"ifood.tv","lastUpdateTimestamp":"2014-04-20T20:34:59","numOfVideos":"15"}
但是,我希望此输出以可读的JSON格式放入文件中,如下所示:
{"type":"Show",
"id":"123",
"title":"name",
"description":"Funny",
"channelTitle":"ifood.tv",
"lastUpdateTimestamp":"2014-04-20T20:34:59",
"numOfVideos":"15"}
如何以这种方式格式化输出?
发布于 2014-12-02 06:24:26
我猜您想要美化JSON输出。这可以通过使用python来实现:
curl http://localhost:8880/test.json | python -mjson.tool > out.json
发布于 2019-03-16 12:25:08
python -m json.tool
Curl http://127.0.0.1:5000/people/api.json | python -m json.tool
也能有所帮助。
发布于 2016-07-20 18:17:21
我发现json_reformat非常方便。所以我只做了以下几件事:
curl http://127.0.0.1:5000/people/api.json | json_reformat
就这样!
https://stackoverflow.com/questions/27238411
复制相似问题