Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to modify external json file javascript

//All Other code has an error 
//Here is the correct one
fs = require('fs');
var name = 'fileName.json';
var m = JSON.parse(fs.readFileSync(name).toString());
for(const p in m){
    p.name= m.name;
}
fs.writeFileSync(name, JSON.stringify(m));
Comment

edit external json file in javascript

fs = require('fs');
var name = 'fileName.json';
var m = JSON.parse(fs.readFileSync(name).toString());
m.forEach(function(p){
    p.name= m.name;
});
fs.writeFileSync(name, JSON.stringify(m));
Comment

js read external json file js

fs = require('fs');
var name = 'myFile.json';
var m = JSON.parse(fs.readFileSync(name).toString());
m.forEach(function(p){
    p.name= m.name;
});
fs.writeFileSync(name, JSON.stringify(m));
Comment

PREVIOUS NEXT
Code Example
Javascript :: form validation using jquery 
Javascript :: two decimel javascript 
Javascript :: get ip address js 
Javascript :: JS append content into a DOM element 
Javascript :: how could you implement javascript into java 
Javascript :: eas build apk 
Javascript :: install react native gifted charts 
Javascript :: changing color of console log 
Javascript :: installing prop-types 
Javascript :: radio button set value in javascript 
Javascript :: get hours and minutes and seconds from date in javascript 
Javascript :: javascript foreach index 
Javascript :: binary agents freecodecamp 
Javascript :: daterangepicker set maxdate 
Javascript :: javascript e.key 
Javascript :: download file javascript 
Javascript :: js spread exclude property 
Javascript :: date-and-time npm 
Javascript :: javascript write text 
Javascript :: regExp numero français 
Javascript :: hide component on click vue 
Javascript :: difference between call and apply in js 
Javascript :: get url params in express 
Javascript :: js narrate text 
Javascript :: fetch in react 
Javascript :: jquery change input value if greater than 
Javascript :: how to reverse number in javascript 
Javascript :: tocapitalize javascript 
Javascript :: nextjs change port 
Javascript :: js promisify in browser 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =