print json data from file to console nodejs code example
Example 1: read json file nodejs
const fs = require('fs');
const path = require('path');
let rawdata = fs.readFileSync(path.resolve(__dirname, 'student.json'));
let student = JSON.parse(rawdata);
console.log(student);
Example 2: js write to json file
fs.writeFile ("file.json", JSON.stringify(data), function(err) {
if (err) throw err;
console.log('complete');
}
);