Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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 load and parse the json data in node js

const data = '{ "name": "Flavio", "age": 35 }'
try {
  const user = JSON.parse(data)
} catch(err) {
  console.error(err)
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: react-native-cli remove 
Javascript :: react native navigation reset history 
Javascript :: disable copy past jquery 
Javascript :: js remove undefined from object 
Javascript :: reinitialize datatable on button click 
Javascript :: month name array javascript 
Javascript :: javascript csv string with commas in fields 
Javascript :: fullscreen mode javascript 
Javascript :: remove attribute javascript 
Javascript :: jquery url change 
Javascript :: edit json via nodejs 
Javascript :: jquery create div element 
Javascript :: get last part of url jquery 
Javascript :: add 1 year to current date javascript 
Javascript :: How to update node.js in replit 
Javascript :: identify unused node modules 
Javascript :: JavaScript Regex - Remove Whitespace from Start and End 
Javascript :: react open a link to an outside siite 
Javascript :: vue input file image preview 
Javascript :: jquery radio button change 
Javascript :: UnhandledPromiseRejectionWarning: MongoNotConnectedError: 
Javascript :: protractor get active element 
Javascript :: how to rotate camera around three JS object 
Javascript :: ajax call with form data 
Javascript :: laravel javascript array from blade 
Javascript :: larger text console javascript 
Javascript :: update the whole target of a proxy javascript 
Javascript :: onclick not getting called from dynamic generated data 
Javascript :: .replace is not a function 
Javascript :: how to remove angular package 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =