<script language="JScript" runat="Server">
function ToObject(json) {
var o;
eval("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>
<%
json = "[{""date"":""週四"",""weather"":""晴"",""wind"":""微風"",""temperature"":""21""}]"
Set ob = toArray(json)
For i=0 To ob.Count-1
Response.Write ob(i)("date") & " "
Response.Write ob(i)("weather") & " "
Response.Write ob(i)("wind") & " "
Response.Write ob(i)("temperature") & " "
Response.Write " "
next
Set ob = Nothing
%>
以上代碼是我在網上找的
在json = "[{""date"":""週四"",""weather"":""晴"",""wind"":""微風"",""temperature"":""21""}]"中
date weather wind temperature
都是用""""包住的 即是""date""
如果我把""date""改為"date"就會出錯
但是我自己的需要是要用"data"而不是""date""
要怎樣才可以用"data"而不是""date""
可能問得不太清楚