npm install json.filed
var jf = require( 'json.filed' );
var jsonfile = jf.filed( '/path/to/jsonFile' );
jsonfile
.read( ( json ) => { < your code > } )
.exec();
For example :
.read( ( json ) => { console.log( json.msg ) } )
Result :
$ node exampleOnHow2Use.js
hello world
jsonfile
.write( <json object to write > )
.exec();
For example :
.write( { msg: 'good after noon' } )
Result :
$ cat data.json
{"msg":"good after noon"}