嘿,我有以下我试图找到的 json 响应:
{
"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],
我正在尝试查找3570956071,但我似乎无法使用 JSON.net 找到它。
我的代码是这样的:
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....
我得到错误:对象引用未设置为对象的实例。
我什至尝试过:
For Each msg3 As JObject In o("threaded_extended")
'etc etc....
并得到错误:无法将“Newtonsoft.Json.Linq.JProperty”类型的对象转换为“Newtonsoft.Json.Linq.JObject”类型。
最后只是这样做:
For Each msg3 As JObject In o("3570956071")
'etc etc....
给我错误:对象引用未设置为对象的实例。
我错过了什么?
更新
o("3570956071") 的值是Nothing。
但正如您在 json 共鸣中看到的那样,它就在那里..
做 o("threaded_extended") 给了我调试中的数字。
调试看起来像这样:
"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
但从那开始,它显示错误无法将“Newtonsoft.Json.Linq.JProperty”类型的对象转换为“Newtonsoft.Json.Linq.JObject”类型