Hi,
I do not know why the JSON is not saved.
I am setting a variable
var settings = { hours : 0, minutes : 0, seconds : 0, started : false, counter : 0 };
Then I store this to a JSON file
const storage = require('Storage'); storage.writeJSON('test.json', settings);
Then I change the variable
settings.counter = 12345;
Then I store again
storage.writeJSON('test.json', settings);
And reload
settings2 = storage.readJSON('test.json',1);
Why is the counter (settings2.counter) not stored? It is 0 after reload, not 12345.
This is the full code.
var settings = { hours : 0, minutes : 0, seconds : 0, started : false, counter : 0 }; const storage = require('Storage'); storage.writeJSON('test.json', settings); settings.counter = 12345; print(settings.counter); //=12345 storage.writeJSON('test.json', settings); settings2 = storage.readJSON('test.json',1); print(settings2.counter); //=0, why is the counter not saved?
Thanks Christian
@Purple-Tentacle started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi,
I do not know why the JSON is not saved.
I am setting a variable
Then I store this to a JSON file
Then I change the variable
Then I store again
And reload
Why is the counter (settings2.counter) not stored? It is 0 after reload, not 12345.
This is the full code.
Thanks
Christian