vb.net 2010 read json url and populate datagridview

I am a complete newbie to .net scene. I have some experience in php but absolutely none in vb.net 2010.

Below is my code that I am trying to read and populate a datagridview.

Imports System.Net
Imports System.IO
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Public Class Form1


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim request As HttpWebRequest
        Dim response As HttpWebResponse = Nothing
        Dim reader As StreamReader
        Dim url As String
        url = base_url & "get_login/dileep/1234"
        request = DirectCast(WebRequest.Create(url), HttpWebRequest)

        response = DirectCast(request.GetResponse(), HttpWebResponse)
        reader = New StreamReader(response.GetResponseStream())

        Dim s As String
        S = reader.ReadToEnd
        Dim arr As Array
        arr = JsonConvert.DeserializeObject < JArray > (s)
        DataGridView1.DataSource = arr
    End Sub
End Class

My issue is that I get this build error which I have no idea on debugging.

  1. Overload resolution failed because no accessible ‘DeserializeObject’ accepts this number of arguments.

  2. ‘JArray’ is a type and cannot be used as an expression.

I just don’t know what to do.

Any help is greatly appreciated.


Source: json

Leave a Reply