我最终通过随机实验得到了它,这产生了一个包含值的字典,它足够接近,所以我可以创建我想要的变量,而不必使用我认为我必须使用的 VB.NET 数组我希望这个帮助他人:
进口:
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
声明的变量:
Dim json As String 'this is the string of json data that needs decoding
Dim version As String
Dim obj As New JObject
转换代码:
json = '{"UPTIME": "UNKNOWN", "VERSION ": 2.0, "SENDTIME": "03:33:52", "SENDDATE": "28- 12-2012", "HOSTNAME": "My-PC"}'
Dim deserializedProduct As Object = JsonConvert.DeserializeObject(Of Object)(json)
obj = JsonConvert.DeserializeObject(recv)
uptime = obj.Item("UPTIME").ToString
version = obj.Item("VERSION").ToString
Console.WriteLine(uptime)
Console.WriteLine(version)
结果:
UNKNOWN
2