Node.js fs read sync json file and parse

Description

Node.js fs read sync json file and parse


var fs = require("fs");
console.log("Starting");
var contents = fs.readFileSync("./files/config.json");
console.log("Contents: " + contents);
var config = JSON.parse(contents);
console.log("Config:", config);
console.log("Username: ", config.username);

//Execute here/*from   ww  w.j a  v  a2  s .c  om*/



PreviousNext

Related