我通过NuGet安装了JSON.Net,现在我想用一个带有对象的json数组解析VB.NET中的对象列表。我不知道从哪里开始。
我的JSON数组:
[
{
"servername": "US - New Jersey",
"ovpnlocation": "servers/newjersey.ovpn"
},
{
"servername": "The Netherlands",
"ovpnlocation": "servers/nl.ovpn"
},
{
"servername": "Belgium",
"ovpnlocation": "servers/belgium.ovpn"
}
]
我有一个我要填充的对象列表:
Dim ServerList As New List(Of ServerLocation)
我的ServerLocation类包含:
Public Property ServerName As String
Public Property OVPNLocation As String
答案 0 :(得分:1)
使用JSON.Net这样的东西应该可以工作,json是一个包含上面列出的JSON的字符串:
Dim ServerList As List(Of ServerLocation) = JsonConvert.DeserializeObject(Of List(Of ServerLocation))(json)