The clues are in your first post, but I don't know how much time you have spent playing around with Collections. As your screen shots show, vNew contains a collection of collections. Each trading pair in the collection contains its own collection of data, where the trading pair name is the Key string.
So I've taken the variant vNew (which is returned from Json.Decode) and copied it into the new collection cBitcoin. Then I enumerate each item in the collection cBitcoin by asking: "FOR EACH collection (ciBitcoin) IN the collection (cBitcoin) please return the Key"
The collection property cBitcoin.Key returns each collection key as a string (e.g. BTC_ETH). And then I can use:
...to get the corresponding Last value.
In VB6 you could also access a collection using a numeric index, something like:
...would give you the 3rd item Key in the collection. But Gambas does not support a numeric index.
I'm glad you used the Poloniex api query: "https://poloniex.com/public?command=returnTicker
..as the main collection only references sub-collections, which makes the code straight forward.
As an additional exercise, I spent an hour or two this morning trying to do the same thing with:
This collection includes a mixture of strings and collections, and I can't think how to deal with this.
What additional data are you trying to retrieve? The remaining data for each trading pair in your example is similar to "last". So for example, if you wanted the 24hr High value use:
Code: Select all
And if you want to filter trading pairs, you could just display Ether markets:
Code: Select all
For Each ciBitcoin In cBitcoin
If InStr(cBitcoin.Key, "ETH") > 0 Then
Print cBitcoin.Key, cBitcoin[cBitcoin.Key]["last"], cBitcoin[cBitcoin.Key]["high24hr"]
I hope this helps, but come back if its still gibberish.