how to include json file in javascript code example
Example 1: how to use json file in nodejs
D:\NodeJs>node readsync.js
*START*
Output Content:
*EXIT*
var fs = require("fs");
console.log("\n *STARTING* \n");
var contents = fs.readFileSync("jsoncontent.json");
var jsonContent = JSON.parse(contents);
console.log("User Name:", jsonContent.username);
console.log("Email:", jsonContent.email);
console.log("Password:", jsonContent.password);
log("\n *EXIT* \n");
Example 2: nodejs include json file
config = require("./yourfile.json");