我有这个 json 数组响应:
[
{
"status": "active",
"url": "https:\/\/ikiosk.podio.com\/dev\/apps\/myusers",
"url_label": "myusers",
"space_id": 550628,
"link_add": "https:\/\/ikiosk.podio.com\/dev\/apps\/2304568\/items\/new",
"app_id": 2304568,
"date_field": false,
"link": "https:\/\/ikiosk.podio.com\/dev\/apps\/myusers",
"config": {
"allow_edit": true,
"description": "",
"item_name": "myusers",
"type": "standard",
"icon_id": 251,
"allow_create": true,
"usage": "",
"icon": "251.png",
"external_id": null,
"name": "myusers"
},
"url_add": "https:\/\/ikiosk.podio.com\/dev\/apps\/2304568\/items\/new"
},
{
"status": "active",
"url": "https:\/\/ikiosk.podio.com\/dev\/apps\/requests",
"url_label": "requests",
"space_id": 550628,
"link_add": "https:\/\/ikiosk.podio.com\/dev\/apps\/2299738\/items\/new",
"app_id": 2299738,
"date_field": true,
"link": "https:\/\/ikiosk.podio.com\/dev\/apps\/requests",
"config": {
"allow_edit": true,
"description": "",
"item_name": "request",
"type": "standard",
"icon_id": 251,
"allow_create": true,
"usage": "",
"icon": "251.png",
"external_id": null,
"name": "Requests"
},
"url_add": "https:\/\/ikiosk.podio.com\/dev\/apps\/2299738\/items\/new"
}
]
这里的课程:
Public Class GetAllApps
Public pApplication As PodioApplication
End Class
Public Class PodioApplication
Public status As String
End Class
我的代码在这里:
Dim client As New RestClient()
client.BaseUrl = "https://api.podio.com/"
Dim request As New RestRequest()
request.RequestFormat = DataFormat.Json
request = New RestRequest()
request.Method = Method.[GET]
request.RequestFormat = DataFormat.Json
request.AddParameter("oauth_token", access_token)
request.Resource = "/app/v2//"
Dim resp = client.Execute(Of List(Of GetAllApps))(request)
RichTextBox1.Text = resp.Content
Dim pApps As List(Of PodioApplication) = resp.Data.[Select](Function(c) c.pApplication).ToList()
MsgBox(pApps.Count)
For Each p As PodioApplication In pApps
MsgBox(p.status)
Next
我之前写的json数组是resp.Content的结果。在代码行 MsgBox(pApps.Count) 我取了正确的数字(在这种情况下是 2)。但是在 for each 循环中,我出现异常错误:“对象引用未设置为对象的实例。”
我的实现有什么问题,缺少什么吗?