我应该如何访问此JSON中的“游戏”数组?我正在使用http://aspjson.com中的课程。
{
"period":[
{
"period_id":"1774",
"start_time_epoch":1431126300,
"games":[
{
"home_team":"WSH",
"away_team":"ATL"
}
]
}
]
}
访问方法:
today = date
For Each key In oJSON.data("period")
Set this = oJSON.data("period").item(key)
periodID = this.item("period_id")
periodDate = FormatDateTime(DateAdd("s", this.item("start_time_epoch"), "01/01/1970 00:00:00"),2)
----Ideally, this.item("games").item("home_team") would have worked.----
if cstr(today) = periodDate then
response.write periodID & " - " & periodDate & "<br/> - " & this.item("games").item("start_time")
end if
Next
答案 0 :(得分:2)
您的JSON无效:http://jsonformatter.curiousconcept.com/
这是有效的:
{
"period":[
{
"period_id":"1774",
"start_time_epoch":1431126300,
"games":[
{
"home_team":"WSH",
"away_team":"ATL"
}
]
}
]
}
要访问主队,您可以使用
Response.Write( oJSON.data("period")(0)("games")(0)("home_team"))