0
由于建议从这里(Looping through JSON using ASPJSON)和这里(ASP JSON: Object not a collection),我开始用JSON数组中的经典ASP:循环通过JSON阵列使用ASPJSON
{"markers": [{
"event":"hard_bounce",
"msg":{
"ts":1365109999,
"subject":"This an example webhook message",
"email":"[email protected]",
"sender":"[email protected]",
"tags":[
"webhook-example"
],
"state":"bounced",
"metadata":{
"user_id":111
},
"_id":"exampleaaaaaaaaaaaaaaaaaaaaaaaaa",
"_version":"exampleaaaaaaaaaaaaaaa",
"bounce_description":"bad_mailbox",
"bgtools_code":10,
"diag":"smtp;550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces."
},
"_id":"exampleaaaaaaaaaaaaaaaaaaaaaaaaa",
"ts":1433940242
},
{
"event":"hard_bounce",
"msg":{
"ts":1365109999,
"subject":"This an example webhook message",
"email":"[email protected]",
"sender":"[email protected]",
"tags":[
"webhook-example"
],
"state":"bounced",
"metadata":{
"user_id":111
},
"_id":"exampleaaaaaaaaaaaaaaaaaaaaaaaaa1",
"_version":"exampleaaaaaaaaaaaaaaa",
"bounce_description":"bad_mailbox",
"bgtools_code":10,
"diag":"smtp;550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces."
},
"_id":"exampleaaaaaaaaaaaaaaaaaaaaaaaaa1",
"ts":1433940242
}]
}
我使用传统的ASP和ASPJSON(http://www.aspjson.com/ )。
我可以从循环通过访问“_id”和“TS”的值:
Set oJSON = New aspJSON
'read the local JSON data
oJSON.loadJSON(str2)
For Each thingy In oJSON.data("markers")
Set this = oJSON.data("markers").item(thingy)
Response.Write _
this.item("_id") & ": " & _
this.item("ts") & "<br>"
Next
但是,我坚持尝试在数据获得下一层的“味精”部分。
我曾尝试:
For Each thingy In oJSON.data("markers")
Set this = oJSON.data("markers").item(thingy)
Response.Write _
this.item("_id") & ": " & _
this.item("ts") & "<br>"
For Each thingy2 In oJSON.data("msg")
Set this2 = oJSON.data("this2").item(thingy2)
Response.Write _
this2.item("subject") & ": " & _
this2.item("diag") & "<br>"
Next
Next
但得到这个错误:
Description: Object not a collection : .
与此相关联行:
对于每个thingy2在oJSON.data( “味精”)
我想我在做一些愚蠢的事情,但我被困在这一个,并不能解决如何访问该数据。