在VB.net中的一些文本框中组织JSON

时间:2017-12-05 22:21:55

标签: json vb.net

我正在尝试反序列化'?从vb.net中的API返回的json 以下是api链接中的JSON:http://yugiohprices.com/api/rising_and_falling

以下是我目前拥有的只捕获JSON的代码:

    Dim request = TryCast(System.Net.WebRequest.Create("http://yugiohprices.com/api/rising_and_falling"), System.Net.HttpWebRequest)

    request.Method = "GET"

    request.ContentLength = 0
    Dim responseContent As String
    Using response = TryCast(request.GetResponse(), System.Net.HttpWebResponse)
        Using reader = New System.IO.StreamReader(response.GetResponseStream())
            responseContent = reader.ReadToEnd()
        End Using
    End Using

我想获得类似于以下内容的结果: textbox_rising内容: (名称: ... 价钱: ... pricehift:...'(必须是正面的) 卡号: ... 卡集:... 稀有:...) (名称: ... 价钱: ... pricehift:...'(必须是正面的) 卡号: ... 卡集:... 稀有:......)等......

textbox_falling内容: (名称: ... 价钱: ... pricehift:...'(必须为负数) 卡号: ... 卡集:... 稀有:...) (名称: ... 价钱: ... pricehift:...'(必须为负数) 卡号: ... 卡集:... 稀有:......)等......

我希望你能理解我的意思,我对JSON不是很熟悉,而且对于vb来说还是比较新的,感谢提前。

编辑:... 课程补充:

Public Class Rising
Public Property name As String
Public Property price As Double
Public Property price_shift As Double
Public Property card_number As String
Public Property card_set As String
Public Property rarity As String
End Class

Public Class Falling
Public Property name As String
Public Property price As Double
Public Property price_shift As Double
Public Property card_number As String
Public Property card_set As String
Public Property rarity As String
End Class

Public Class Data
Public Property rising As Rising()
Public Property falling As Falling()
End Class

Public Class rfJSON
Public Property status As String
Public Property data As Data
End Class

已添加代码:

Dim obj = JsonConvert.DeserializeObject(Of rfJSON)(responseContent)
txt_rising.Text = obj.ToString

0 个答案:

没有答案