-3
我工作的一個傳統的ASP項目,我用ASP的Xtreme進化解析JSON數據JSON數據(這裏找到:How to access JSON data in classic ASP using json2.asp or aspjson libraries?) 我試過,但我不能。我如何訪問這個json數據?如何訪問在傳統的ASP
{
"result":[
{
"key":"2607037",
"sts":"finished",
"stsdetail":"Finished",
"sname":"Ice Hockey",
"home":{
"1p":"0",
"fe":"2",
"3p":"1",
"2p":"1",
"ord":"2",
"rs":"2"
},
"away":{
"ord":"0",
"1p":"0",
"rs":"0",
"2p":"0",
"3p":"0",
"fe":"0"
}
},
{
"key":"2435948",
"sts":"finished",
"stsdetail":"Finished",
"sname":"Soccer",
"home":{
"ord":"2",
"rs":"2",
"fe":"2",
"ht":"1"
},
"away":{
"ord":"0",
"rs":"0",
"fe":"0",
"ht":"0"
}
},
{
"key":"2606031",
"sts":"cancelled",
"stsdetail":"Cancelled",
"sname":"Tennis"
}
]
}
代碼:
set restaurant = oJSON.data("result")
for each itm in restaurant
if Not IsObject(restaurant.item(itm)) then
Response.write itm &" : "& restaurant.item(itm) & "<br/>"
else
'opening
for each dayy in restaurant.item(itm)
Response.write dayy & ":"
Response.write restaurant.item(itm)(dayy)
If restaurant.item(itm)(dayy) <> "" Then
Response.write " - "
Response.write restaurant.item(itm)(dayy)
End If
Response.write "<br/>"
next
end if
您可以使用Ajax調用來調用'.json'文件或API端點訪問它。 – MrNew