转换JSON数组到VB.净数组



JSON数组如下:

[
{
"label": "google.com",
"value": "google.com"
},
{
"label": "google.co.in",
"value": "google.co.in"
},
{
"label": "google.de",
"value": "google.de"
},
{
"label": "google.co.uk",
"value": "google.co.uk"
},
{
"label": "google.co.jp",
"value": "google.co.jp"
},
{
"label": "google.fr",
"value": "google.fr"
},
{
"label": "google.com.br",
"value": "google.com.br"
},
{
"label": "google.ru",
"value": "google.ru"
},
{
"label": "google.it",
"value": "google.it"
},
{
"label": "google.es",
"value": "google.es"
}
]

我需要采取"value":或"label:"的东西,并在VB.net中创建一个数组,将包含他们的文本。

google.comgoogle.co.in等。等。

我有JSON。网络图书馆. .

创建这个类:

Class Product
    Public Value As String
End Class

使用此代码:

Try
    TextBoxX1.AutoCompleteCustomSource.Clear()
Catch ex As Exception
End Try
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://www.alexa.com/wwwdata/autocomplete?q=" & TextBoxX1.Text & "&limit=10")
Dim response As System.Net.HttpWebResponse = request.GetResponse()
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
Dim sourcecode As String = sr.ReadToEnd()
Dim products As List(Of Product) = JsonConvert.DeserializeObject(Of List(Of Product))(sourcecode)
For Each SiteName As Product In products
    TextBoxX1.AutoCompleteCustomSource.Add(SiteName.Value)
Next

相关内容

  • 没有找到相关文章

最新更新