How can I pretty-print JSON using node.js?

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, and util.inspect doesn't produce valid json. :\ I found no [native] solution to pretty printing JSON in NodeJS

以上就是How can I pretty-print JSON using node.js?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JSON 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准