将VB.NET中的Json解析为listview

时间:2014-11-21 06:07:19

标签: json vb.net parsing listview

我正在开发Minecraft的costum发射器,具有更多功能。我在解析这个json文件时遇到问题:https://s3.amazonaws.com/Minecraft.Download/versions/versions.json(我使用Newtonsoft.json解析),我想解析,并在listview中显示结果(如:http://pbrd.co/1ueP2Su),但我不知道代码可以做什么。 Sory因为我的英语不好,谢谢你的帮助!

1 个答案:

答案 0 :(得分:1)

如果您创建一个可能如下所示的新结构:

Public Structure Version
    Public ID As String
    Public TIME As String
    Public releaseTime As String
    Public type As String
End Structure

然后,也许按下按钮,写下这个

    Dim allVersions = New List(Of Version)
    Using wc = New WebClient() With {.Proxy = Nothing}
        Dim JSON = Await wc.DownloadStringTaskAsync("https://s3.amazonaws.com/Minecraft.Download/versions/versions.json") 'Downloads the JSON file
        Dim values = JsonConvert.DeserializeObject(Of JObject)(JSON) 'Converts it to JObject

        For Each i In values("versions").Children() 'Gets the versions
            YOUR_LISTBOX.Items.Add(i.ToObject(Of Version).ID)
        Next
    End Using