Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to update a json file javascript

const fs = require('fs');
const fileName = './file.json';
const file = require(fileName);
    
file.key = "new value";
    
fs.writeFile(fileName, JSON.stringify(file), function writeJSON(err) {
  if (err) return console.log(err);
  console.log(JSON.stringify(file));
  console.log('writing to ' + fileName);
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: elevation react native 
Javascript :: jquery validator no space 
Javascript :: check if number is integer js 
Javascript :: three js get size of object 
Javascript :: nuxt head script content 
Javascript :: javascript deep clone 
Javascript :: jquery checkbox 
Javascript :: execute javascript when page finished loading 
Javascript :: device width js 
Javascript :: js last word in a string 
Javascript :: javascript object destructuring rename 
Javascript :: jquery ajax form submission 
Javascript :: javascript reduce array of objects 
Javascript :: javascript seconds to date 
Javascript :: jquery confirm dialog 
Javascript :: trunc number javascript 
Javascript :: react native socket io 
Javascript :: if select option disabled jquerz 
Javascript :: react native scaling font 
Javascript :: chart js x axis start at 0 
Javascript :: tolowercase 
Javascript :: js transitions 
Javascript :: how to get datetime in nodejs 
Javascript :: vue js required props 
Javascript :: ex. javascript loop aray 
Javascript :: vue js cdn link 
Javascript :: how to change tab color react bootstraps customixation 
Javascript :: ... unicode 
Javascript :: javascript count instances in string 
Javascript :: what is data node in big data 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =