Answers for "json file to json object node js"

4

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);
Posted by: Guest on April-13-2020
2

read json file node js

function readJsonFile(file) {
    let bufferData = fs.readFileSync(file)
    let stData = bufferData.toString()
    let data = JSON.parse(stData)
    return data
}
Posted by: Guest on June-07-2021
0

nodejs include json file

config = require("./yourfile.json"); // Note, "config" can be changed to your liking.
Posted by: Guest on January-15-2021

Code answers related to "json file to json object node js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language