This is NeutralinoJS storage API for writing JSON. Is it possible to update JSON file (push data), not just overwrite data with new JS object. How to do that?
// Javascript Object to be stored as JSON
let data = {
bucket : 'test',
content : {
item : 10
}
}
// stores the data into JSON based data store.
Neutralino.storage.putData(data,
// executes on successful storage of data
function () {
console.log('Data saved to storage/test.json');
},
// executes if an error occurs
function () {
console.log('An error occured while saving the Data');
}
);
The
Neutralino.storage
api takes string instead of JSON to save into local storage.And you can create your JavaScript Objects to String Very easily, for example:
Here you can see how we used
JSON.stringify
method to convert our JavaScript Object into string.Now We Can Also Convert generated string back to our javascript object, example:
So now we can easily store our Objects and arrays to local storage and easily modify them, example: