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?
UPDATE
Doing o("threaded_extended") gives me the number within the debug.
The debug looks like this:
Code:
"3570956071": [
{
"chat_client_sequence": null,
"replied_to_id": [edited],
"network_id": [edited],
"created_at": "2013/08/27 19:26:41 +0000",
"privacy": "public",
"attachments": [],
"sender_id": [edited],
"liked_by": {
"names": [],
"count": 0
},
"system_message": false,
"group_id": [edited],
"thread_id": [edited],
'etc etc
But continuing from that it shows that error Unable to cast object of type 'Newtonsoft.Json.Linq.JProperty' to type 'Newtonsoft.Json.Linq.JObject'
Then i did this:
Code:
For Each msg3 As JToken In o("threaded_extended")
If msg3 Is JObject Then
End If
Next
And that works with the o("threaded_extended") but theres an error on If msg3 Is JObject Then saying JObject' is a type and cannot be used as an expression.