如何使用Node-orm2将json对象打印到db

时间:2020-12-26 21:44:07

I'm using node-orm2 to persist a model to a mysql db column. It works great, except I want the written json pretty printed, so I can easily read it when I view the DB.
Is this possible?

我正在使用node-orm2将模型持久化到mysql db列。它工作得很好,除了我想要写的json很漂亮,所以当我查看数据库时我可以很容易地阅读它。这可能吗?

1 个解决方案

#1


1  

you can use JSON stringify with params:

你可以使用带有params的JSON stringify:

var obj = {manu: true, gili: "abc"}
var str = JSON.stringify(obj, null, 4); // spacing = 4

#1


1  

you can use JSON stringify with params:

你可以使用带有params的JSON stringify:

var obj = {manu: true, gili: "abc"}
var str = JSON.stringify(obj, null, 4); // spacing = 4