2015-03-19 69 views
0

你好IM使用json_encode節省.txt文件一個PHP數組,接下來,我需要使用這個數組在vb.net,但我真的可以做一個或同時爲每個, 這是陣列字符串什麼是反序列化的正確方法?

"[{"Id_Event":"5713616","Deporte":"Soccer","Pais":"Austria Amateur","Liga":"Regionalliga East","Jornada":"20","Local":"SKU Amstetten","Visita":"Wiener SC Axa","Fecha_Evento":"2015-03-18T19:30:00","encuentros":[{"Items":[{"Por":"1","Fila":"3way15713616","Cuota":"1.9","$$hashKey":"019"}],"Tipo":"3way","Gan_Max":1.9,"$$hashKey":"017"}],"$$hashKey":"015"},{"Id_Event":"6804834","Deporte":"Soccer","Pais":"England Amateur","Liga":"Southern Football League,","Jornada":"1","Local":"Cambridge City","Visita":"Frome Town","Fecha_Evento":"2015-03-18T20:45:00","encuentros":[{"Items":[{"Por":"1","Fila":"3way16804834","Cuota":"1.7","$$hashKey":"01F"}],"Tipo":"3way","Gan_Max":1.7,"$$hashKey":"01D"}],"$$hashKey":"01B"}]" 

在項目中,我有Imports Newtonsoft.Json.Linq

請幫我

回答

1

你可以反序列化JSON你的List(Of JObject)的最簡單的方法能夠通過JSON數組遍歷:

Dim jsonString As String = "your_json_text" 
Dim json As List(Of JObject) = JsonConvert.DeserializeObject(Of List(Of JObject))(jsonString) 
For Each jObject As JObject In json 
    Console.WriteLine(jObject) 
Next 

更好的方法是創建一個類來映射您的json數組中的每個項目,然後將您的json反序列化爲List(Of YourClass)而不是List(Of JObject)

相關問題