JSON.NET 反序列化问题
我一整天都在为下一个 JSON 字符串而苦苦挣扎,
{
"0":{"link":"afbeeldingenplaatje1.jpg"},
"1":{"link":"afbeeldingenplaatje2.jpg"},
"2":{"link":"afbeeldingenplaatje3.jpg"}
}
我该如何反序列化它?下一个代码(vb.net)有什么问题,
Public Class DataString
Private m_link As String
Public Property link() As String
Get
Return m_link
End Get
Set(ByVal value As String)
m_link = value
End Set
End Property
End Class
Public Class DataToArray
Private a_Data As Dictionary(Of Integer, DataString)
Public Property DataTo() As Dictionary(Of Integer, DataString)
Get
Return a_Data
End Get
Set(ByVal value As Dictionary(Of Integer, DataString))
a_Data = value
End Set
End Property
Dim template As DataToArray = JsonConvert.DeserializeObject(Of DataToArray)(sData)
它总是返回空结果。
谢谢!
雷蒙德
I'm strugling the whole day with the next JSON string
{
"0":{"link":"afbeeldingenplaatje1.jpg"},
"1":{"link":"afbeeldingenplaatje2.jpg"},
"2":{"link":"afbeeldingenplaatje3.jpg"}
}
How can i deserialize this? What's wrong with the next code (vb.net)
Public Class DataString
Private m_link As String
Public Property link() As String
Get
Return m_link
End Get
Set(ByVal value As String)
m_link = value
End Set
End Property
End Class
Public Class DataToArray
Private a_Data As Dictionary(Of Integer, DataString)
Public Property DataTo() As Dictionary(Of Integer, DataString)
Get
Return a_Data
End Get
Set(ByVal value As Dictionary(Of Integer, DataString))
a_Data = value
End Set
End Property
Dim template As DataToArray = JsonConvert.DeserializeObject(Of DataToArray)(sData)
it returns always an empty result.
Thanks!
Raymond
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
json 数据和您的模型不匹配。
尝试这样做:
或者将数据输入更改为:
The json data and your model does not match.
Try doing this instead:
Or change the data input to: