Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27349

VS 2010 Json.net start from value in array

$
0
0
Hey all i have the following json response that i am trying to find:
Code:

{
"threaded_extended": {
"3570956071": [
  {
    "id": [edited],
    "network_id": [edited],
    "sender_type": "user",
    "url": "[edited]",
    "sender_id": [edited],
    "privacy": "public",
    "body": {
      "rich": "[edited]",
      "parsed": "[edited]",
      "plain": "[edited]"
    },
    "liked_by": {
      "count": 0,
      "names": []
    },
    "thread_id": [edited],I am trying to find 3570956071 but i cant seem to find it using JSON.net.

My code is this:
Code:

    Dim url As String = "https://www.[edited].json?access_token=" & yAPI.userToken & "&threaded=extended"
    Dim request As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
    Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
    Dim reader As StreamReader = New StreamReader(response.GetResponseStream())
    Dim o As JObject = JObject.Parse(reader.ReadToEnd)

For Each msg3 As JObject In o("threaded_extended")("3570956071")
'etc etc....And i get the error: Object reference not set to an instance of an object.

I have even tried:
Code:

For Each msg3 As JObject In o("threaded_extended")
'etc etc....And get the error: Unable to cast object of type 'Newtonsoft.Json.Linq.JProperty' to type 'Newtonsoft.Json.Linq.JObject'.

And finally just doing this:
Code:

For Each msg3 As JObject In o("3570956071")
'etc etc....gives me the error: Object reference not set to an instance of an object.

What am i missing?

Viewing all articles
Browse latest Browse all 27349

Trending Articles