通过使用经典 ASP 解析 JSON 来提取值

Extracting values by parsing JSON with Classic ASP

我正在使用 Classic ASP 和 ASPJSON (http://www.aspjson.com/) 来尝试在通过以下方式发送电子邮件时提取以 JSON 格式返回的数据SendGrid API.

这是一些示例 JSON 数据:

{  
   "message":"error",
   "errors":[  
      "some errors"
   ]
}

我可以通过以下方式访问 "message" 部分的值:

Set oJSON = New aspJSON
oJSON.loadJSON(string_containing_json)

json_status = ap(oJSON.data("message"))

response.write(json_status)

但是,我无法访问 "errors" 部分的值,因为它有点低一级。

有可能做到吗?

错误存储为字典对象。您可以像这样枚举它们:

dim errors : set errors = oJSON.data("errors")
dim curError
for curError = 0 to errors.Count -1
  Response.Write( errors(curError))
  Response.Write( "<br />")
next