File types bangle can read/parse?

Posted on
  • Hello

    I am writing a clock face which will show cricket scores. I currently have the layout sorted with a working clock and date. The scores are hard coded and drawn from source at the moment. Eventually when the android app integration can do internet access it will hopefully update automatically. The next step is to manually add a file to storage for the app to parse.

    My question is what types of file can be read? Obviously json but can it read XML or HTML?

    Many thanks
    Pete

  • Hi, there's no parser for XML I'm afraid but you might be able to bodge something up.

    Personally I'd say JSON or CSV, but there was some talk of having some code that ran on the phone, so potentially you could do parsing in that, convert to JSON and send that over

  • Ok, thanks for the info. I'll have a tinker. It's all very new to me but good fun and I'm learning

  • http://www.espruino.com/Reference#t_StorĀ­age

    JSON is easiest since there is built in support for reading to and writing from JSON files with automatic parsing/serialization with the Storage.readJSON and
    Storage.writeJSON. But you can use Storage.read and Storage.write for other formats, you just have to handle the parsing yourself.

    Also see this guide:
    http://www.espruino.com/Bangle.js+StoragĀ­e

  • Thanks for pointing me to these, I'll have a good read. I have it reading a manually written and pushed JSON file using require("Storage").readJSON. The key will be to get an automatically generated JSON file but that won't happen until there is internet implementation.

    I have been uploading my JSON file by typing into the webIDE editor and pushing to storage. Every time I do it it creates an error and crashes the watch as it does not like the colons. Resetting the watch then works fine with the updated JSON read properly. Is there a better way to write and upload the file to the watch?

  • Hmm if typing the JSON manually maybe run it through a JSON validator tool like this one: https://jsonlint.com/

    In the web IDE you can also just upload a file directly from your computer.

  • Perfect. Thanks. I missed the upload a file option!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

File types bangle can read/parse?

Posted by Avatar for petefrommars @petefrommars

Actions