我已经在classic ASP(VBScript)中找到了无数用于generating个JSON的库,但我在parsing个中没有找到任何库.

我想要一些可以传递JSON字符串并返回某种类型的VBScript对象(数组、脚本、字典等)的东西

有谁能推荐一个在classic ASP中解析JSON的库吗?

推荐答案

Keep in mind that Classic ASP includes JScript as well as VBScript. Interestingly, you can parse JSON using JScript and use the resulting objects directly in VBScript.

Therefore, it is possible to use the canonical https://github.com/douglascrockford/JSON-js/blob/master/json2.js in server-side code with zero modifications.

Of course, if your JSON includes any arrays, these will remain JScript arrays when parsing is complete. You can access the contents of the JScript array from VBScript using dot notation.

<%@Language="VBScript" %>
<%
Option Explicit
%>

<script language="JScript" runat="server" src='path/to/json2.js'></script>

<%

Dim myJSON
myJSON = Request.Form("myJSON") // "[ 1, 2, 3 ]"
Set myJSON = JSON.parse(myJSON) // [1,2,3]
Response.Write(myJSON)          // 1,2,3
Response.Write(myJSON.[0])      // 1
Response.Write(myJSON.[1])      // 2
Response.Write(myJSON.[2])      // 3
%>

Json相关问答推荐

如何循环访问多个子数组并在单个JSON中检索数据点

如何用JQ更改空/布尔/数字的 colored颜色 ?

Vega-Lite(Deneb):难以将最小和最大值应用于折线图和文本标签以及线条末尾的点

在Vega中如何通过滑块改变条形图的宽度

创建Json嵌套文件 struct

使用JQ将对象数组转换为平面数组

NoneType 对象的 Python 类型错误

将 json 转换为 jsonb 安全吗?

遍历 JSON,检索父值

JSON 的自定义编组器,可以是字符串或 map[string]string / map[string]bool

通过 xslt 将内部 json 转换为 xml 时遇到问题

Powershell 7.2:ConvertFrom-Json - 日期处理

如果有 1 个元素,如何防止 ConvertFrom-Json 折叠嵌套数组

Rails 控制器无需编码即可渲染 json

为什么在测试 RSPEC 时 JBuilder 不返回 JSON 中的响应正文

Angularjs访问本地json文件

如何在已声明的 JSON 对象中添加键值对

IE10/11 Ajax XHR 错误 - SCRIPT7002:XMLHttpRequest:网络错误 0x2ef3

如何向 json IAM 策略添加 comments ?

JSON键是否需要唯一?