Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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));
 
PREVIOUS NEXT
Tagged: #modify #external #json #file #javascript
ADD COMMENT
Topic
Name
9+3 =