+ 2
Is it possible to edit external JSON file data by just JavaScript pure ?
( Main.js ) (File.json)
2 Answers
+ 2
Frontend javascript is sandboxed, it cannot modified any external files.
Use server script, node.js.
+ 2
You can't save in a file using client-side script, you have to use some server-side scripting like PHP, NodeJS etc. to save something in a file.
For example in NodeJS you can use the fs library:
// load file system package
var fs = require('fs');
// to read
var data = JSON.parse(fs.readFileSync('data.json').toString());
// to write
fs.writeFile('data.json', JSON.stringify(data));
Hope it helps.