Gili Nachum Gili Nachum - 1 year ago 93
JSON Question

How to pretty print json objects to db using Node-orm2

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?

Answer Source

you can use JSON stringify with params:

var obj = {manu: true, gili: "abc"}
var str = JSON.stringify(obj, null, 4); // spacing = 4
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download