ASP读取JSON数组的问题。求解啊!!!!
JSON的数组为:{"date":"周四08月07日(实时:2)","weather":"晴","wind":"微风","temperature":"21"},{"dat...
JSON的数组为:
{"date":"周四 08月07日 (实时:2)","weather":"晴","wind":"微风","temperature":"21"},{"date":"周五","weather":"多云","wind":"微风","temperature":"31 ~ 22"},{"date":"周六","weather":"多云转阴","wind":"微风","temperature":"30 ~ 22"},{"date":"周日","weather":"阴转晴","wind":"微风","temperature":"31 ~ 22"}
这里面有多个date和weather等值
请问我怎么用ASP循环出来这些值呢?
我现在是这样做的
<script language="JScript" runat="Server">
function toObject(json) {
eval("var o=" + json);
return o;
}
</script>
<%
Dim json
json = "上面那些JSON数组"
Set json = toObject(json)
Response.Write json.date ‘这里目前只能读出到一个DATE
Set json = Nothing
%>
我实在是没分了。急求!!!! 展开
{"date":"周四 08月07日 (实时:2)","weather":"晴","wind":"微风","temperature":"21"},{"date":"周五","weather":"多云","wind":"微风","temperature":"31 ~ 22"},{"date":"周六","weather":"多云转阴","wind":"微风","temperature":"30 ~ 22"},{"date":"周日","weather":"阴转晴","wind":"微风","temperature":"31 ~ 22"}
这里面有多个date和weather等值
请问我怎么用ASP循环出来这些值呢?
我现在是这样做的
<script language="JScript" runat="Server">
function toObject(json) {
eval("var o=" + json);
return o;
}
</script>
<%
Dim json
json = "上面那些JSON数组"
Set json = toObject(json)
Response.Write json.date ‘这里目前只能读出到一个DATE
Set json = Nothing
%>
我实在是没分了。急求!!!! 展开
2个回答
展开全部
<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"":""周四 08月07日 (实时:2)"",""weather"":""晴"",""wind"":""微风"",""temperature"":""21""},{""date"":""周五"",""weather"":""多云"",""wind"":""微风"",""temperature"":""31 ~ 22""},{""date"":""周六"",""weather"":""多云转阴"",""wind"":""微风"",""temperature"":""30 ~ 22""},{""date"":""周日"",""weather"":""阴转晴"",""wind"":""微风"",""temperature"":""31 ~ 22""}]"
Set ob = toArray(json)
For i=0 To ob.Count-1
Response.Write ob(i)("date") & " <br/>"
next
Set ob = Nothing
%>
注意JSON字符串前后的 [ ]
展开全部
$.each(data.json, function (i,r) {var xx=r.xxxx
var xxx=r.xxxxx})
http://blog.csdn.net/songylwq/article/details/6047609
var xxx=r.xxxxx})
http://blog.csdn.net/songylwq/article/details/6047609
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询