I am making a extension for Google Chrome where i have to store JSON file. Now my extension need to upgrade the JSON file frequently.
Is there any way to upgrade the JSON file using plain java script without the “reading->editing->writing” cycle that means i can just push the update in the file directly.
Yup,i can do that writing some cutting edge code , i just want to know if there is a built- in way .
I am new in javacript realm. So providing resources while answering will be a great help.
And i prefer a solution in plain JS not in any frameworks.
Feel free to share any other better approach to do that.
UPDATED with example :
Lets assume there is a json file which have following value:
{"name" : "X"}
Now , i want to update “name”= “Y” directly into the file so it pushes the update to the json file.
{"name" : "Y"}
And also i may need to add a new node like “age”:”20″ and i would like it to push the update in the json file which will look like :
{"name" : "Y" , "age": "20"}
I am newbie in JS so maybe i failed to explain it precisely . I tried my best.
Most newer versions of browsers support a filesystem API.
Take a look at this:
http://www.html5rocks.com/en/tutorials/file/filesystem/
There’s also a library that implements the W3C
saveAs()candidate (though I think this has been dropped from the spec these days).https://github.com/eligrey/FileSaver.js