use external json file in javascript code example
Example 1: 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));
Example 2: 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));