我目前正在使用以下JSON格式提取Poloniex returnCompleteBalances信息:
{“LTC”:{“available”:“5.015”,“onOrders”:“1.0025”,“btcValue”:“0.078”},“NXT:{...} ...}
我正在尝试将信息添加到我制作的类中,并将不同的硬币(属性名称)及其相关信息分开。到目前为止,我有以下内容:
Sub GetBalances()
Dim method As String = calldata("returnCompleteBalances")
Dim allData As JObject = JObject.Parse(method)
Dim coinlist As New List(Of balancedata)
For Each token As JToken In allData("objects")
Dim prop As JProperty = token
coinlist.Add(New balancedata With {.Coin = prop.Name, .available = prop.Value("available"), .onOrders = prop.Value("onOrders"), .btcValue = prop.Value("btcValue")})
Next
End Sub
和班级
Public Class balancedata
Public Property Coin As String
Public Property available As Decimal
Public Property onOrders As Decimal
Public Property btcValue As Decimal
结束班
当我运行代码时,我在每个标记上收到一个错误,如Jtoken行所示:“对象引用未设置为对象的实例”
我该如何解决这个问题?我不知道属性名称,LTC,BTC等的所有值。所以我试图仔细查看它们并将相关值逐项列表到列表中。