1
我試圖使用Json.net將JSON從Application Insights Analytics(AIA)反序列化到我的類中。我不知道如果我接近它的權利,但我使用LINQ到JSON獲得在JSON的數據部分,然後嘗試使用此代碼反序列化到我的課:使用Json.net反序列化應用程序Insights Analytics
Dim rawjson As String = GetTelemetry()
Dim o As JObject = JObject.Parse(rawjson)
Dim ds = DirectCast(o("Tables")(0)("Rows"), JArray)
Dim Sessions As List(Of Session) = JsonConvert.DeserializeObject(Of List(Of Session))(ds)
這由於AIA的JSON採用以下格式,因此失敗:
"Rows": [
[
"Boy",
"9",
"",
"",
"0",
"0",
"22",
"0"
],
[
"Boy",
"9",
"",
"",
"0",
"0",
"41",
"0"
],
請注意,單個行的數據是數組而非對象。
我Session
類的定義是這樣的:
Public Class Session
Public Property Gender As String
Public Property Age As Integer
Public Property SessionVids As Integer
Public Property TotalVids As Integer
Public Property ChildUse As Integer
Public Property ChildTime As Integer
Public Property AdultUse As Integer
Public Property AdultTime
End Class
能有人請解釋如何做到這一點?
什麼是您試圖反序列化到'Session'類的定義是什麼? –
公共堂課 公共財產性別作爲字符串 公共財產年齡作爲整數 公共財產SessionVids作爲整數 公共財產TotalVids作爲整數 公共財產ChildUse作爲整數 公共財產ChildTime作爲整數 公共財產AdultUse作爲整數 公共財產AdultTime End Class – Maf
@BrianRogers有什麼想法? – Maf