var c = require("Storage").readJSON("myfile.json",true);
console.log("type of c is " + typeof(c));
If I am reading the documentation correctly, if myfile.json is mangled, c should be set to undefined, but my app simply dies and never logs anything at all. (If myfile.json doesn't exist, c is set to undefined as expected.) If I change "true" to "false", a syntax error is logged and then the app dies. For the record, myfile.json contained "#0f0" when I discovered the issue, which I am currently working around with try/catch.
Ahh - thanks! So just to confirm:
var c = require("Storage").readJSON("myfile.json",true)||"error";print("Got",c);
Doesn't print anything, when it should have printed Got error. It basically stops execution right after readJSON.
I've just fixed the error, so new builds should have the fix in
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem