ASP 解析json
第一个方法是使用 JScript : <script language="jscript" runat="server">
Array.prototype.get = function(x) { return this[x]; };
function parseJSON(strJSON) { return eval("(" + strJSON + ")"); }
</script> <%
Dim json, obj
json = "{a:""aaa"", b:{ name:""bb"", value:""text"" }, c:[""item0"", ""item1"", ""item2""]}"
Set obj = parseJSON(json) Response.Write obj.a & "<br />"
Response.Write obj.b.name & "<br />"
Response.Write obj.c.length & "<br />"
Response.Write obj.c.get(0) & "<br />" Set obj = Nothing
%> <script language="JScript" runat="Server"> function ToObject(json) {
var o;
eval("o=" + json);
return o;
}
</script>
<%
set obj1 = ToObject("{aaa:""aaaa"", bbb: ""bbbb""}")
Response.Write obj1.aaa & "<br />"
%>
第二个方法是使用MS的脚本控件(也一样是使用了 JScript):
Dim scriptCtrl
Function parseJSON(str)
If Not IsObject(scriptCtrl) Then
Set scriptCtrl = Server.CreateObject("MSScriptControl.ScriptControl")
scriptCtrl.Language = "JScript"
scriptCtrl.AddCode "Array.prototype.get = function(x) { return this[x]; }; var result = null;"
End If
scriptCtrl.ExecuteStatement "result = " & str & ";"
Set parseJSON = scriptCtrl.CodeObject.result
End Function Dim json
json = "{a:""aaa"", b:{ name:""bb"", value:""text"" }, c:[""item0"", ""item1"", ""item2""]}" Set obj = parseJSON(json) Response.Write obj.a & "<br />"
Response.Write obj.b.name & "<br />"
Response.Write obj.c.length & "<br />"
Response.Write obj.c.get(0) & "<br />" Set obj = Nothing Set scriptCtrl = Nothing
ASP 解析json的更多相关文章
- Asp.net 解析json
Asp.net Json数据解析的一种思路 http://www.cnblogs.com/scy251147/p/3317366.html http://tools.wx6.org/json2csha ...
- ASP.net解析JSON例子
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- ASP.NET 使用 System.Web.Script.Serialization 解析 JSON (转)
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.易于人阅读和编写.同时也易于机器解析和生成.它基于JavaScript Programming Langu ...
- asp.net中json格式化及在js中解析json
类: public class UploadDocumentItem { public UploadDocumentItem() { } public string DocMuid { get; se ...
- ASP.net解析JSON
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- 《项目经验》--通过js获取前台数据向一般处理程序传递Json数据,并解析Json数据,将前台传来的Json数据写入数据库表中
先看一下我要实现的功能界面: 这个界面的功能在图中已有展现,课程分配(教师教授哪门课程)在之前的页面中已做好.这个页面主要实现的是授课,即给老师教授的课程分配学生.此页面实现功能的步骤已在页面 ...
- 使用 dynamic 标记解析JSON字符串 JDynamic :支持Json反序列化为Dynamic对象
使用 dynamic 标记解析JSON字符串 http://www.cnblogs.com/taotaodetuer/p/4171327.html 1 string jsonStr = " ...
- IIS支持解析json
IIS支持解析json 一. windows XP 1. MIME设置: 在IIS的站点属性的HTTP头设置里,选MIME 映射中点击"文件类型"-"新类型&qu ...
- (转)c# 解析JSON的几种办法
来自:http://blog.csdn.net/gaofang2009/article/details/6073029 欲成为海洋大师,必知晓海中每一滴水的真名. 刚开始只是想找一个转换JSON数组的 ...
随机推荐
- MyBatis一个对多个主键(索引)生成实体类的处理
原数据库表: 生成实体类,多出了一个xxKey.java
- C++ delete仍可访问的问题
C++ delete和置为NULL 先上一段代码: class Object { public: explicit Object(int num) : m_num(num){} void functi ...
- octave-bug - 报告 GNU Octave 中的 bug
SYNOPSIS 总览 octave-bug [-s subject] DESCRIPTION 描述 octave-bug 是一个 shell 脚本,用于以一种标准的格式撰写有关 Octave 的 b ...
- ES调优
ES Connection timed out,调优方向 1. 使用游标滚动查询 scrollId 游标id searchResponse.getScrollId() scroll 设置游标的保留时间 ...
- 牛客练习赛49 B 筱玛爱阅读 (状压DP,子集生成)
链接:https://ac.nowcoder.com/acm/contest/946/B 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262875K,其他语言5257 ...
- hdlg WM_INITDIALOG
https://www.cnblogs.com/gakusei/articles/1585212.html // “关于”框的消息处理程序. LRESULT CALLBACK About(HWND h ...
- ztree 获取CheckBox选中节点时,不获取选中上级父节点
//将第三个参数改为false,表示不去勾选父节点下的所有子节点 zTreeObj.checkNode(node, true, false); setting.check.chkboxType = { ...
- 日记(OI 无关,文化课无关)
2019.11.13 今天在研究 wss 的代码为什么比我快那么多. 看见他定义了一个结构体叫 thxorz,一定是因为 orz 了 thx 得到了信仰加成了. 然后刚说完这句话就看见 thx 走了进 ...
- 【Luogu4221】[WC2018] 州区划分
题目链接 题目描述 略 Sol 一个州合法就是州内点形成的子图中 不存在欧拉回路(一个点也算欧拉回路). 这个东西显然就状压 dp 一下: 设 \(f[S]\) 表示当前考虑了 \(S\) 这个集合内 ...
- python-语言播报
利用系统自带模块: 在cmd中 python -m pip install pypiwin32 安装win32com模块 import win32com.client sp=win32co ...