Arrays 无法使用Github中的JsonConverter.bas在Excel VBA中的JSON中循环嵌套数组
我的JSON文件如下所示:Arrays 无法使用Github中的JsonConverter.bas在Excel VBA中的JSON中循环嵌套数组,arrays,json,vba,nested,Arrays,Json,Vba,Nested,我的JSON文件如下所示: { "data": [ { "id": "6003510075864", "name": "Golf", "audience_size": 242637550, "path": [ "Interests", "Sports and outdoors", "Sports", "G
{
"data": [
{
"id": "6003510075864",
"name": "Golf",
"audience_size": 242637550,
"path": [
"Interests",
"Sports and outdoors",
"Sports",
"Golf"
],
"description": "",
"topic": "Sports and outdoors"
},
{
"id": "6003393973731",
"name": "Persian Gulf",
"audience_size": 173453990,
"path": [
"Interests",
"Additional Interests",
"Persian Gulf"
],
"description": null,
"topic": "Hobbies and activities"
},...
如您所见,存在一个长度未知的嵌套数组“path”
使用此代码,我尝试访问以下部分:
Dim hReq As Object, JSON As Object, item As Object, itempath As Object
(...)
For Each item In JSON("data")
ws.Cells(3 + i, 1) = item("id")
ws.Cells(3 + i, 2) = item("name")
ws.Cells(3 + i, 3) = item("audience_size")
ws.Cells(3 + i, 4) = item("description")
ws.Cells(3 + i, 5) = item("topic")
For Each itempath In item("path") ' <<< in this line I get the error Object needed..
ws.Cells(3 + i, 6) = itempath("0")
Next
i = i + 1
Next
Dim hReq作为对象,JSON作为对象,item作为对象,itempath作为对象
(...)
对于JSON中的每个项目(“数据”)
ws.Cells(3+i,1)=项(“id”)
ws.Cells(3+i,2)=项(“名称”)
ws.Cells(3+i,3)=项目(“受众大小”)
ws.Cells(3+i,4)=项目(“说明”)
ws.Cells(3+i,5)=项(“主题”)
对于项目中的每个项目路径(“路径”)'
…是字符串的集合,而不是对象的集合
Dim itempath 'as variant
'...
For Each itempath In item("path")
ws.Cells(3 + i, 6) = itempath
Next
'...
好的,谢谢你,蒂姆。。。但我不得不使用变体。。。无论如何……)
Dim itempath 'as variant
'...
For Each itempath In item("path")
ws.Cells(3 + i, 6) = itempath
Next
'...