任何好的库经典ASP JSON解析? [英] Any good libraries for parsing JSON in Classic ASP?
问题描述
我已经能够找到的生成经典ASP(VBScript)的JSON是数不胜数库,但我一直没找到任何对于解析
I've been able to find a zillion libraries for generating JSON in Classic ASP (VBScript) but I haven't been to find ANY for parsing.
我想要的东西,我可以通过一个JSON字符串并取回某种形式的VBScript的对象(数组,的Scripting.Dictionary等)
I want something that I can pass a JSON string and get back a VBScript object of some sort (Array, Scripting.Dictionary, etc)
推荐答案
记住,传统的ASP的JScript包括和VBScript中。有趣的是,你可以使用JScript和直接在VBScript中使用生成的对象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.
因此,可以使用正则<一href=\"https://github.com/douglascrockford/JSON-js/blob/master/json2.js\">https://github.com/douglascrockford/JSON-js/blob/master/json2.js在服务器端code零修改。
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.
当然,如果你的JSON包括任何阵列,这些都将解析完成时保持的JScript数组。你可以使用点符号从VBScript访问JScript数组的内容。
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
%>
这篇关于任何好的库经典ASP JSON解析?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!