Reputation: 1082
How should I access the "games" array within this JSON? I'm using the class from http://aspjson.com.
{
"period":[
{
"period_id":"1774",
"start_time_epoch":1431126300,
"games":[
{
"home_team":"WSH",
"away_team":"ATL"
}
]
}
]
}
Method of access:
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
Upvotes: 2
Views: 730
Reputation: 1225
Your JSON is not valid: http://jsonformatter.curiousconcept.com/
This would be valid:
{
"period":[
{
"period_id":"1774",
"start_time_epoch":1431126300,
"games":[
{
"home_team":"WSH",
"away_team":"ATL"
}
]
}
]
}
To access the home team you can use
Response.Write( oJSON.data("period")(0)("games")(0)("home_team"))
Upvotes: 2