这些数据我得到的
{
"s": "ok",
"t": [
1509469200,
1509469500,
1509469800,
1509470100,
1509470400,
1509470700,
1509471000
],
"r": [
6040100,
5955000,
5955000,
5999600,
5999400,
5999000,
5960100
],
"v": [
3.06575198,
7.92733913,
6.04823174,
0.87041449,
0.27879491,
0.31525724,
0.08880846
]
}
我可以通过此代码获得S值,然后返回"确定"。
Dim pData = JsonConvert.DeserializeObject(response_)
Dim status As String = pData("s")
但是我有其他值的错误,如何将t,r,s,v作为数组或此json的字符串列表?
Dim time_ As List(Of String) = pData("t")
Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'System.Collections.Generic.List`1[System.String]'.
创建一个类
Public Class JSON_result
Public Property s As String
Public Property t As Integer()
Public Property r As Integer()
Public Property v As Double()
End Class
然后将JSON供该类的对象。
Dim obj = JsonConvert.DeserializeObject(Of JSON_result)(response_jsonString)
现在您可以访问属性为
obj.s
和数组元素为 obj.t(0)
obj.r(0)
obj.v(0)