arrays - ASP JSON : Multidimensional JSON array

标签 arrays json asp-classic

我应该如何访问此 JSON 中的“games”数组?我正在使用 http://aspjson.com 中的类(class).

{
"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

最佳答案

您的 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"))

关于arrays - ASP JSON : Multidimensional JSON array,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30132184/

相关文章:

php - 数组索引自动从 1 开始

c# - Json Serialize Dictionary<Enum, Int32> 的问题

java - JAX-RS JSON 编码后缺少子对象

xml - 解析YouTube XML

java - 在数组中添加数组

arrays - 如何查找落在给定区间内的数组元素?

php - 我的 IF 语句有问题

javascript - 尝试将数据推送到 JSON 数组

javascript - 使用 Javascript 从经典 ASP 中的文件中读取文本

asp-classic - 从 fso 对象创建 ado 记录集