json 增加记录
I am tired of logging JSON and seeing [Object]
or [Array]
on my terminal.
我厌倦了记录JSON并在终端上看到[Object]
或[Array]
。

So I set out on a mission to do something about it. Enter jq, a lightweight and flexible command-line JSON processor. You can follow the installation guide in the docs for your OS.
所以我开始执行一项任务。 输入jq ,这是一个轻量级且灵活的命令行JSON处理器。 您可以按照适用于您的操作系统的文档中的安装指南进行操作。
Now all you have to do is console.log(JSON.stringify(data))
and pipe the command you run to jq. Like shown below:
现在您所要做的就是console.log(JSON.stringify(data))
并将您运行的命令通过管道传递给jq。 如下图所示:
node index.js | jq
Which will output this beautiful JSON ✨ that we wanted in the first place.
它会首先输出我们想要的漂亮的JSON✨。

Hope you found the article useful. Let me know your thoughts in the comments below or you can @ me on twitter
希望您觉得这篇文章有用。 在下面的评论中让我知道您的想法,或者您可以在Twitter上@我
翻译自: https://medium.com/@VamsiRao7/make-your-logged-json-readable-4846405bb55f
json 增加记录