ASP当前位置:首页 > 教程 > Web 开发 > ASP

请问ASP显示JSON格式的数据

发布时间:2013-12-21来源:互联网作者:佚名
{"weatherinfo":{"city":"南京","cityid":"101190101","temp1":"-1","temp2":"11","weather":"多云转晴","img1":"n1.gif","img2":"d0.gif","ptime":"18:00"}}


请问如何怎么用ASP的方法把下面的城市,天气显示出来?
2013-12-12 00:31:50 hookee
<script language="JScript" runat="server">
var s = '{"weatherinfo":{"city":"南京","cityid":"101190101","temp1":"-1","temp2":"11","weather":"多云转晴","img1":"n1.gif","img2":"d0.gif","ptime":"18:00"}}';
var obj = eval("(" + s + ")");
city = obj.weatherinfo.city;
weather = obj.weatherinfo.weather;
</script>
<%
Response.Write city & " : " & weather
%>
2013-12-12 10:57:21 ww_super
<script language="JScript" runat="Server"> 
function toObject(json) {
eval("var o=" + json);
return o; 

</script> 
<% 
Dim json
json = "{""weatherinfo"":{""city"":""南京"",""cityid"":""101190101"",""temp1"":""-1"",""temp2"":""11"",""weather"":""多云转晴"",""img1"":""n1.gif"",""img2"":""d0.gif"",""ptime"":""18:00""}}"
Set json = toObject(json) 
Response.Write json.weatherinfo.city & "<br/>" 
Response.Write json.weatherinfo.weather & "<br/>"
Set json = Nothing 
%>  
参与评论已经有 人参与
请自觉遵守互联网相关的政策法规1,严禁发布色情、暴力、反动的言论。
网站首页|FYCMS官网|网站地图|
收缩