Q:

node save json to file

let data = JSON.stringify(student);
fs.writeFileSync('student-2.json', data);
1
const fs = require('fs');
const path = require('path');

let student = { 
    name: 'Mike',
    age: 23, 
    gender: 'Male',
    department: 'English',
    car: 'Honda' 
};
 
fs.writeFileSync(path.resolve(__dirname, 'student.json'), JSON.stringify(student));
6

New to Communities?

Join the community