Reading JSON Files from local system with Node.js
Oct 20, 2020
Read the JSON data from the file we can use the Node.js fs module.
There are two functions available in this module that we can use to read files from the file system: readFile and readFileSync
Example1-
const fs = require(‘fs’);
const fileUrl = new URL(‘file:///C:/Users/sanjsingh/Desktop/student.json’);
let data = fs.readFileSync(fileUrl);
let student = JSON.parse(data);
console.log(student);