Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

read json file node js

function readJsonFile(file) {
    let bufferData = fs.readFileSync(file)
    let stData = bufferData.toString()
    let data = JSON.parse(stData)
    return data
}
Comment

node.js read json file

//Condensed
JSON.parse(fs.readFileSync("path").toString())
Comment

how to read a json file in node js

const path = require('path')
const fs = require('fs')

blogs = JSON.parse(fs.readFileSync(path.join(__dirname, '../data/blogs.json')).toString())
Comment

read a json in nodejs

'use strict';

const fs = require('fs');

fs.readFile('student.json', (err, data) => {
    if (err) throw err;
    let student = JSON.parse(data);
    console.log(student);
});

console.log('This is after the read call');
Comment

how to get json data from json file in node js

const fs = require("fs"); 
var posts = [];

fs.readFile('./data/posts.json', 'utf8', (err, data) => {
                if (err) throw err;
                posts = JSON.parse(data);
            });
Comment

how to use json file in nodejs

// Read Synchrously
var fs = require("fs");
console.log("
 *START* 
");
var content = fs.readFileSync("content.txt");
console.log("Output Content : 
"+ content);
console.log("
 *EXIT* 
");
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript object array merge 
Javascript :: javascript set readonly property 
Javascript :: classlist remove all classes 
Javascript :: do not trigger useeffect on start 
Javascript :: flatlist listemptycomponent center 
Javascript :: express js cors 
Javascript :: set bg image in react 
Javascript :: form append other data feild and send through ajax 
Javascript :: useMediaQuery react hook 
Javascript :: how to write img jsx 
Javascript :: how to copy text in the clipboard in js 
Javascript :: knockout dump variable 
Javascript :: How to iterate over the DOM 
Javascript :: howt to disable a select tag using js 
Javascript :: javascript add element next to another 
Javascript :: await fetch in react 
Javascript :: js load multiple images 
Javascript :: javascript substring after character 
Javascript :: find element in array javascript 
Javascript :: how to show only few first elements of array js 
Javascript :: js check proccess alive 
Javascript :: Javascript file in html angeben 
Javascript :: filter duplicates from array javascript 
Javascript :: last item in object javascript 
Javascript :: how to pass props in react test cases 
Javascript :: move dom element to another parent 
Javascript :: js object for each 
Javascript :: js json groupby prop 
Javascript :: react detect screen size 
Javascript :: router.query is undefined in first render 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =