我收到格式化为
的信息 {"UFs": [
{
"Valor": "24.184,92",
"Fecha": "2014-10-07"
}
]}
我希望能够访问此处显示的值和日期。
我有一个班级
Public Class clValores
Private pTipoValores As String
Private pValores As String
Public Property Fecha() As String
Get
Return pTipoValores
End Get
Set(ByVal value As String)
pTipoValores = value
End Set
End Property
Public Property Valor() As String
Get
Return pValores
End Get
Set(ByVal value As String)
pValores = value
End Set
End Property
End Class
这段代码
Dim webClient As New System.Net.WebClient
Dim result As String = webClient.DownloadString("http://api.sbif.cl/api-sbifv3/recursos_api/uf?apikey=xxxxxxxxxxxxxxxxxxxxxxx&formato=JSON")
Dim Valor As clValores = JsonConvert.DeserializeObject(Of clValores)(result)
Response.Write(Valor.Fecha)
Response.Write(Valor.Valor)
但是在运行代码时,Valor什么都没有。我缺少什么
答案 0 :(得分:0)
从我在post中读到的内容,它就像简单地包装UFs参数一样简单,所以要创建一个包含
的额外类Public Class UFsContainer
public UFs as List(Of clValores)
End Class
然后使用新类而不是clValores
反序列化它答案 1 :(得分:0)
将Imports System.Collections.Generic
添加到您的项目中,然后创建另一个如下所示的类-
Public Class UFsContainer
public UFs as List(Of clValores)()
End Class
然后将其反序列化为-
Dim Valor As UFsContainer = JsonConvert.DeserializeObject(Of UFsContainer)(result)