Accessing rows in an AppMessage pebble array

I am creating an Internet-connected BitCoin application. Watch ticker information from various bitcoin markets. Everything works. Now I want to send a list of available markets down to the clock, which will be displayed as a menu. JSON will be sent:

{"markets": ["MtGox", "BitStamp","BTCChina"]}

"markets" are correctly entered in "appinfo.json", so this is not a problem.

How do I access an element (single row) in this array on Pebble? I saw examples of accessing ints and strings directly, and they work fine, are there any good examples of this? I have not found.

+6
source share
1 answer

I assume that you are using the PebbleKit JS API. The relevant document is located at: https://developer.getpebble.com/2/guides/javascript-guide.html

The document says that you can send dictionaries with values ​​like ints, string or byte arrays.

To send a list of strings, you have different options.

  • Send a few key / value pairs starting at a known index

     { 100: "MtGox", 101: "BitStamp", 102: "BTCChina" } 
  • Send one line with a known separator and divide it into hours

     { "markets": "MtGox|BitStamp|BTCChina" } 
  • Send an array of bytes with a list of keys that contain the name of the market

     { "markets": [100, 101, 102], 100: "MtGox", 101: "BitStamp", 102: "BTCChina" } 
+13
source

Source: https://habr.com/ru/post/959131/


All Articles