<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
'''''下面這個(gè)測(cè)試了幾次,不用數(shù)組還不行,asp操作這個(gè)的確沒有 asp.net 方便,時(shí)間不夠,也不管什么性能,就這樣放著吧,拼一個(gè)數(shù)據(jù),然后取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
%>