<script language="JScript" runat="Server">
function toObject(json) {
eval("var o=" + json);
return o;
}
function toArray(s){
var dic = Server.CreateObject("Scripting.Dictionary")
eval("var a=" + json);
for(var i=0;i<a.length;i++){
var obj = Server.CreateObject("Scripting.Dictionary")
for(x in a[i]) obj.Add(x,a[i][x])
dic.Add(i, obj);
}
return dic;
}
</script>
<%
Dim json
json ="[{'uid':'1','username':'abc','email':'123@163.com'},{'uid':'2','username':'dbc','email':'456@163.com'}]"
Set json = toArray(json)
For i=0 To json.Count-1
Response.Write json(i)("uid") & " <br/>"
Response.Write json(i)("username") & " <br/>"
Response.Write json(i)("email") & " <br/>"
Next
Set json = Nothing
'''''下面这个测试了几次,不用数组还不行,asp操作这个的确没有 asp.net 方便,时间不够,也不管什么性能,就这样放着吧,拼一个数据,然后取0算了。。
json ="[{'uid':'1','username':'abc','email':'123@163.com'}]"
Set json = toArray(json)
Response.Write json(0)("uid") & " <br/>"
Response.Write json(0)("username") & " <br/>"
Response.Write json(0)("email") & " <br/>"
Set json = Nothing
%>