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 :: javascript remove a specific item from an array 
Javascript :: jquery empty and append 
Javascript :: run a loop inside a console.log no blank line 
Javascript :: nl2br in jquery 
Javascript :: discordjs delete all messages in channel 
Javascript :: string to ascii javascript 
Javascript :: angular 8 to 9 
Javascript :: remove everything except alphabet and number js 
Javascript :: javascript decimal to string 
Javascript :: insertbefore jquery 
Javascript :: remove white space from string in js 
Javascript :: remove first char javascript 
Javascript :: jquery datetimepicker example code 
Javascript :: mktime in js 
Javascript :: javascript order array by date 
Javascript :: Detecting a mobile browser 
Javascript :: rgb to hex js 
Javascript :: How to add and play sounds in JS 
Javascript :: reset form javascript/jquery 
Javascript :: jquery disable keypress 
Javascript :: firebase timestamp 
Javascript :: JS get min date 
Javascript :: export variables react 
Javascript :: javascript setattribute 
Javascript :: Sort to reverse from an array in javascript 
Javascript :: datatable column width 
Javascript :: toggle classname onclick react 
Javascript :: js get bytearray from file 
Javascript :: convert a string to a number in javascript 
Javascript :: EVERY METHOD 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =