我正在嘗試將This Data轉換爲結構。在VB.NET中轉換JSON數據
我有結構爲這樣:
Public Structure cChartData
Public cUDate As String
Public cOpen As Double
Public cClose As Double
Public cHigh As Double
Public cLow As Double
End Structure
,並以班級爲這樣:
Friend Class ChartData
Public Property uDate() As String
Get
Return m_date
End Get
Set
m_date = Value
End Set
End Property
Private m_date As String
Public Property high() As String
Get
Return m_high
End Get
Set
m_high = Value
End Set
End Property
Private m_high As String
Public Property low() As String
Get
Return m_low
End Get
Set
m_low = Value
End Set
End Property
Private m_low As String
Public Property open() As String
Get
Return m_open
End Get
Set
m_open = Value
End Set
End Property
Private m_open As String
Public Property close() As String
Get
Return m_close
End Get
Set
m_close = Value
End Set
End Property
Private m_close As String
Public Property volume() As String
Get
Return m_volume
End Get
Set
m_volume = Value
End Set
End Property
Private m_volume As String
Public Property quoteVolume() As String
Get
Return m_quoteVolume
End Get
Set
m_quoteVolume = Value
End Set
End Property
Private m_quoteVolume As String
Public Property weightedAverage() As String
Get
Return m_weightedAverage
End Get
Set
m_weightedAverage = Value
End Set
End Property
Private m_weightedAverage As String
End Class
我正在嘗試從各行中的所有變量。除了日期之外,我得到了所有這些。我使用下面的代碼(其中chartInfo = JSON數據):
Dim cdata = JsonConvert.DeserializeObject(Of List(Of ChartData))(chartInfo)
Dim cResData(cdata.Count - 1) As cChartData
For i = 0 To cdata.Count - 1
cResData(i).cUDate = cdata(i).uDate
cResData(i).cOpen = Convert.ToDouble(cdata(i).open)
cResData(i).cClose = Convert.ToDouble(cdata(i).close)
cResData(i).cHigh = Convert.ToDouble(cdata(i).high)
cResData(i).cLow = Convert.ToDouble(cdata(i).low)
Next
Return cResData
的日期返回一個「空白」的值,或什麼都沒有,顯示時,但所有其他值返回正常。這是第一個值,所以我想知道它是否與它有關...
任何幫助,非常感謝。
我已經發布了正在用作主鏈中超鏈接的JSON數據.... –
對不起,沒有看到它。更新了我的答案。 –
問題被命名爲「日期」,但使用[日期]完美工作。非常感謝! –