json2.asp数据解析不工作
我正在使用aspjson json2.asp解析来自factual.com的数据,但我遇到了一些问题 json数据的结构如下所示:json2.asp数据解析不工作,json,asp-classic,Json,Asp Classic,我正在使用aspjson json2.asp解析来自factual.com的数据,但我遇到了一些问题 json数据的结构如下所示: { "version":3, "status":"ok", "response":{ "data":[ { "address":"12725 SW Pacific Hwy", "alcohol":true, "attire":"casual", "category_ids":[358],
{
"version":3,
"status":"ok",
"response":{
"data":[
{
"address":"12725 SW Pacific Hwy",
"alcohol":true,
"attire":"casual",
"category_ids":[358],
"category_labels":[["Social","Food and Dining","Restaurants","Italian"]],
"country":"us","cuisine":["Italian","Pizza","Deli","European","Cafe"],
"factual_id":"22f39245-7435-4e64-b288-9d84f6f20df9",
"groups_goodfor":true,
"kids_goodfor":true,
"latitude":45.42775,
"locality":"Portland",
"longitude":-122.77711,
"meal_breakfast":true,
"meal_cater":true,
"meal_deliver":false,
"meal_dinner":true,
"meal_lunch":true,
"meal_takeout":true,
"name":"New York New York",
"neighborhood":["Bull Mountain","Tigard","Robinson","SW Portland","Jean","Greton"],
"parking":true,
"parking_lot":true,
"parking_street":true,
"postcode":"97223",
"price":2,
"rating":3,
"region":"OR",
"reservations":true,
"seating_outdoor":true,
"status":"1",
"tel":"(503) 443-2404",
"website":"http://www.nynytigard.com",
"wifi":false},
and many other records.......
}]
}
这是我在ASP页面上用来解析数据的脚本:
url_factual="http://api.v3.factual.com/t/restaurants-us?q=%22New%20York%22&KEY=MY_KEY"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET", url_factual, false
xmlhttp.send ""
Dim oJSON
Set oJSON = New aspJSON
oJSON.loadJSON(xmlhttp.responseText)
for each data_object in oJSON.data("response")
for each elemento In oJSON.data("response").item("data")
response.write(oJSON.data("response").item("data").item("address") & "<br>")
response.write(oJSON.data("response").item("data").item("attire") & "<br>")
response.write("----------------------------------------------------<br>")
next
next
'Response.Write oJSON.JSONoutput()
Set oJSON = Nothing
set xmlhttp = nothing
问题是我没有价值观。代码中有什么错误?
感谢您的宝贵帮助。Mick是什么意思?经典asp和json?这是一项非常古老的技术,具有非常新的功能one@MickJSON是JavaScript,JavaScript甚至比经典的asp。。。你的评论毫无帮助。有两件事值得一试。使用Server.CreateObject而不仅仅是CreateObject——我认为这是用于客户端vbs的。也可以尝试MSXML2.ServerXMLHTTP.6.0,而不是MSXML2.ServerXMLHTTP-如果您使用IIS7或更高版本。谢谢John,我尝试过,但仍然没有。。。。for循环正在正确迭代,但看起来oJSON.dataresponse.itemdata.itemaddress为空