Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

write json file in node js

function writeJsonFile(file, content) {
  let jsonData = JSON.stringify(content)
  fs.writeFileSync(file, jsonData)
}
Comment

write json file nodejs

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));
Comment

PREVIOUS NEXT
Code Example
Javascript :: scroll to class jquery 
Javascript :: flexbox stretch height 
Javascript :: square every digit javascript 
Javascript :: javascript get date midnight today 
Javascript :: how to get greatest common divisor in javascript 
Javascript :: remove value from array javascript 
Javascript :: how to edit the link in a href with jquery 
Javascript :: js round up decimal 
Javascript :: react how to scroll to element 
Javascript :: how to reset form values in jquery 
Javascript :: js remove json value duplicates 
Javascript :: js array none 
Javascript :: work gants noir nitrile 
Javascript :: add a text on last object map reactjs 
Javascript :: empty body in get request fetch api 
Javascript :: tailwind css not working with react 
Javascript :: emmet react self closing tags 
Javascript :: Generating a seed file in sequelize 
Javascript :: make created element brighter 
Javascript :: angular pipe json error 
Javascript :: javascript array key value html select 
Javascript :: Codewars Century From Year 
Javascript :: enable input jquery 
Javascript :: vanilla javascript set display 
Javascript :: create array initialize size javascript 
Javascript :: javascript auto save input 
Javascript :: odoo popup input not taking keyboard value 
Javascript :: javascript reload page one time 
Javascript :: download image from url javascript 
Javascript :: jquery get date from datepicker 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =