我使用aspjson
(json2.asp)来解析来自factual.com
的数据,但我遇到了一些问题。
json数据的结构如下:
{
"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
问题在于我没有价值观。代码中有什么问题? 谢谢你的宝贵帮助。