In my web application, javascript code, I have created a JSON object, or actually, list of the json objects. I want to save this into my .json file inside the file structure of my project. How can I do that?
I have this piece of code that actually parse the json and allows to save it, but not automatically, it just popups the window in the browser with the option to save it somewhere by the user:
function saveJSON(text, filename){
var a = document.createElement('a');
a.setAttribute('href', 'data:text/plain;charset=utf-8,'+encodeURIComponent(text));
a.setAttribute('download', filename);
a.click()
}
saveJSON( JSON.stringify(result), "filename.json" );