日期:2014-05-17 浏览次数:20515 次
String jsonString = "{\"weatherinfo\":{\"city\":\"北京\",\"cityid\":\"101010100\",\"temp\":\"25\",\"WD\":\"西南风\",\"WS\":\"3级\",\"SD\":\"59%\",\"WSE\":\"3\",\"time\":\"16:00\",\"isRadar\":\"1\",\"Radar\":\"JC_RADAR_AZ9010_JB\"}}"; var scriptSerializer = new JavaScriptSerializer(); var weatherinfo = scriptSerializer.Deserialize<Dictionary<String, Dictionary<String, String>>>(jsonString); var detail = weatherinfo[""]; //detail["city"];//取得北京。同样获取其他信息。
------解决方案--------------------
可以用JavaScript,比如json赋值给res
var sJson=eval(res); for(var i=0;i<sJson.length;i++) { document.getElementById("div1").innerHTML += "sJson[i].city:sJson[i].cityid"+ "温度:sJson[i].temp"+ "时间:sJson[i].time"; }