Using System; using System. data; using System. configuration; using System. collections; using System. web; using System. web. security; using System. web. UI; using System. web. UI. webControls; using System. web. UI. webControls. webParts; using System. web. UI. htmlControls; // Add System in the project first. web. extensions reference. net 3.5 using System. web. script. serialization; using System. collections. specialized; using System. collections. generic; using System. text; using System. net; namespace JSONFromCS {public partial class WebForm3: System. web. UI. page {// <summary> /// deserialize json data to Dictionary // </summary> /// <param name = "jsonData"> json data </ param> // <returns> </returns> private Dictionary <string, object> JsonToDictionary (string jsonData) {// instantiate the new instance of the JavaScriptSerializer class JavaScriptSerializer jss = new JavaScriptSerializer (); try {// convert the specified JSON string to a Dictionary <string, object> type object return jss. deserialize <Dictionary <string, object> (jsonData);} catch (Exception ex) {throw new Exception (ex. message );}} /// <summary> //// </summary> /// <param name = "sender"> </param> /// <param name = "e "> </param> protected void Page_Load (object sender, eventArgs e) {string url =" http://www.weather.com.cn/data/cityinfo/101280601.html "; WebClient wc = new WebClient (); wc. encoding = System. text. encoding. UTF8; // define the object language string json = wc. downloadString (url); // string json = "{\" weatherinfo \ ": {\" city \ ": \" Shenzhen \ ", \" cityid \": \ "101280601 \", \ "temp \": \ "32 \", \ "WD \": \ "southwest wind \", \ "WS \": \ "Level 4 \", \ "SD \": \ "68% \", \ "WSE \": \ "4 \", \ "time \": \ "16:40 \", \ "isRadar \": \ "1 \", \ "Radar \": \ "JC_RADAR_AZ9755_JB \"}}"; stringBuilder strb = new StringBuilder (); Dictionary <string, object> dic = JsonToDictionary (json); // convert Json data to dictionary format Dictionary <string, object> dataSet = (Dictionary <string, object>) dic ["weatherinfo"]; // use KeyValuePair to traverse data foreach (KeyValuePair <string, object> item in dataSet) {strb. append (item. key + ":" + item. value + "<br/>"); // displayed on the page} Response. write (strb. toString ());}}}