【发布时间】:2019-08-21 05:39:26
【问题描述】:
Json 字符串没有正确反序列化
玩过我的课程等,但 bfevent 总是返回 Nothing 已经尝试过 Public Property bfevent As BFEvent() 以防它需要能够获取多个值
很确定这很简单......
strcatalogue = "{ "jsonrpc": "2.0", "result": [{ "event": { "id": "29202748", "name": "Kings XI Punjab v Mumbai Indians", "countryCode": "GB", "timezone": "GMT", "openDate": "2019-03-30T10:30:00.000Z" }, "marketCount": 20 }, { "event": { "id": "29201119", "name": "Victoria v NSW Blues", "countryCode": "AU", "timezone": "GMT", "openDate": "2019-03-27T23:30:00.000Z" }, "marketCount": 2 }, { "event": { "id": "29202753", "name": "Chennai Super Kings v Rajasthan Royals", "countryCode": "GB", "timezone": "GMT", "openDate": "2019-03-31T14:30:00.000Z" }, "marketCount": 35 }], "id": 1 }"
Dim objJson = JsonConvert.DeserializeObject(Of BFEventList)(strCatalogue)
Public Class BFEvent
Public Property id As String
Public Property name As String
Public Property countryCode As String
Public Property timezone As String
Public Property openDate As DateTime
End Class
Public Class BFResult
Public Property bfevent As BFEvent
Public Property marketCount As Integer
End Class
Public Class BFEventList
Public Property jsonrpc As String
Public Property result As BFResult()
Public Property id As Integer
End Class
BFEvent = 没有
marketCount 工作正常,所以与 BFEvents 类有关
【问题讨论】:
-
似乎课程很好,你得到什么错误?
-
没有错误 - 只是无法为 bfevent 返回任何内容。 bfevent=nothing marketcount=1
-
已添加图片
-
您正在尝试读取引用类的值
-
问题是 class= Nothing 当它应该有 5 个值时