This project has moved. For the latest updates, please go here.

jobject.parse problems (Facebook Graph API)

Oct 15, 2010 at 1:54 PM

I'm completely new to JSON, and I'm running into some problems (trying to do something fairly simple, I think).

I'm integrating an ASP.NET application with the Facebook API (authentication).  I get the access_token, pass it back to Facebook, and Facebook returns the following JSON:

{"id":"123345","name":"Chris Smith","first_name":"Chris","last_name":"Smith","link":"http:\/\/\/profile.php?id=12345","about":"About Text.","bio":"I am a facebook user.","gender":"male","timezone":-4,"locale":"en_US","verified":true,"updated_time":"2010-08-10T16:41:28+0000"}

My code to get the JSON back, and parse it is:

Public Sub getUserData(ByVal token As String)
        Dim url As String = "" & Replace(token, "%7C", "|")
            Dim myHttpWebRequest As HttpWebRequest = WebRequest.Create(url)
            Dim myHttpWebResponse As HttpWebResponse = myHttpWebRequest.GetResponse()
            If myHttpWebRequest.HaveResponse Then
                Dim recvStream As Stream = myHttpWebResponse.GetResponseStream()
                Dim readStream As New StreamReader(recvStream)
                Dim strJson As String = readStream.ReadToEnd
                Dim u As JObject = JObject.Parse(strJson)
                lblCode.Text = strJson
            End If
        Catch ex As Exception
        End Try
    End Sub

If I change it to lblCode.text = u.Count.ToString, I can see that the u object contains 12 elements (the number of elements in the JSON).  But when I try something like lblCode.text = u("name").ToString, I get nothing back.

Am I missing something?

Oct 28, 2010 at 1:33 PM


Am I approaching this the wrong way?