json 增加记录_使您记录的json可读

json 增加记录

I am tired of logging JSON and seeing [Object] or [Array] on my terminal.

我厌倦了记录JSON并在终端上看到[Object][Array]

Image for post

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✨。

Image for post

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 增加记录

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值