This seems like a solved problem but I am unable to find a solution for it.
Basically, I read a JSON file, change a key, and write back the new JSON to the same file. All works, but I loose the JSON formatting.So, instead of:
{
name:'test',
version:'1.0'
}
I get
{name:'test',version:'1.1'}
Is there a way in Node.js to write well formatted JSON to file ?
JSON.stringify
chokes on cyclic objects, andutil.inspect
doesn't produce valid json. :\ I found no [native] solution to pretty printing JSON in NodeJS – ThorSummoner