2v20 writeJSON optimization broke my app [Workaround] #6577
Replies: 1 comment
-
Posted at 2024-01-25 by user140377 Not sure what the problem is, when I try the attached script on 2v20.27 I get
no error. Posted at 2024-01-25 by user140377 Also you might want to check issues#3110 and try the new Util.readStorageJSON() (or replicate what it does after downloading the files from the IDE) Posted at 2024-01-25 by @gfwilliams So I think the issue you have is just that the Emulator was out of date, so wouldn't load those files? As mentioned if you're using the app loader to load then it can automatically parse the new format. I've just updated the emulator, so that should be fixed for you now too Posted at 2024-01-25 by TTBangler Oh--I hadn't noticed that the emulator was out of date, thank you @gfwilliams for updating it and resolving my issue! And thank you @user140377 for advising me about Util.readStorageJSON(). Posted at 2024-01-26 by user140377 @gfwilliams Could we also currently have an issue with backup/restore? I just tried a backup from one Watch and restore on the other and the json files can no longer be read, e.g. sched:
Posted at 2024-01-26 by @gfwilliams Is the watch you restored onto running up to date firmware? If the firmware was older than 2v20 then you'd have an issue I didn't think it should be a problem as the files for backup should be read/written in binary. Posted at 2024-01-26 by user140377 Sorry my fault, I thought I updated. Firmware .20 works. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2024-01-25 by TTBangler
Hello,
I recently upgraded my Bangle1 to 2v20 and discovered that the writeJSON optimization that skips quotes on alphanumeric field names broke my apps. My use case is probably uncommon but I thought I'd mention the workaround I came up with just in case it ever helps anybody else.
Basically, I gather data on my Bangle and save it to JSON formatted files. Using the IDE I export the files to my computer, then import them back into the Bangle emulator. I then run different Bangle apps in the emulator to graph the data (and take screenshots of the graphs).
Anyway, starting with 2v20, writeJSON skips the quotes on alphanumeric field names and because of this, when I used readJSON in the emulator to load the files imported from my Bangle I got a syntax error complaining about the missing quotes. I guess it would be nice for there to be an option added to writeJSON to still include the quotes but until then a simple workaround is just to use write("filename", JSON.stringify("json value")) in lieu of writeJSON("filename", "json value").
I've uploaded a sample script to replicate the problem with my workaround commented out.
As always, many thanks to Gordon and the Espruino team for all their amazing and wonderful work!
Attachments:
Beta Was this translation helpful? Give feedback.
All reactions