I'm building a internet connected BitCoin app. To watch the ticker info from different bitcoin markets. Everything works. Now I want to send a list of available markets down to the watch to be displayed as a menu. JSON to be sent:
{"markets": ["MtGox", "BitStamp","BTCChina"]}
"markets" is properly keyed in "appinfo.json" so this is not a problem.
How do I access an element (single string) in this array on the Pebble? I've seen examples of accessing ints and strings directly and these work great, are there any good examples of this? I have not found any.
I am assuming you are using the PebbleKit JS API. The appropriate doc is at: https://developer.getpebble.com/2/guides/javascript-guide.html
The doc says you can only send dictionaries with values as ints, strings, or byte arrays.
To send a list of strings, you have different options.
Send several key/value pairs, starting at a known index
{ 100: "MtGox", 101: "BitStamp", 102: "BTCChina" }
Send one string with a known separator and split it on the watch
{ "markets": "MtGox|BitStamp|BTCChina" }
Send an array of bytes with a list of keys that contain a market name
{ "markets": [100, 101, 102],
100: "MtGox", 101: "BitStamp", 102: "BTCChina"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With