字符串如下:{"weatherinfo":{"city":"广州","city_en":"guangzhou","date_y":"2012年10月25日","date":"","week":"星期四","fchh":"08","cityid":"101280101","temp1":"30℃~19℃","temp2":"30℃~20℃","temp3":"29℃~21℃","temp4":"29℃~21℃","temp5":"29℃~18℃","temp6":"26℃~16℃","tempF1":"86℉~66.2℉","tempF2":"86℉~68℉","tempF3":"84.2℉~69.8℉","tempF4":"84.2℉~69.8℉","tempF5":"84.2℉~64.4℉","tempF6":"78.8℉~60.8℉","weather1":"晴","weather2":"晴转多云","weather3":"多云","weather4":"晴转多云","weather5":"多云转小雨","weather6":"小雨","img1":"0","img2":"99","img3":"0","img4":"1","img5":"1","img6":"99","img7":"0","img8":"1","img9":"1","img10":"7","img11":"7","img12":"99","img_single":"0","img_title1":"晴","img_title2":"晴","img_title3":"晴","img_title4":"多云","img_title5":"多云","img_title6":"多云","img_title7":"晴","img_title8":"多云","img_title9":"多云","img_title10":"小雨","img_title11":"小雨","img_title12":"小雨","img_title_single":"晴","wind1":"微风","wind2":"微风","wind3":"微风","wind4":"微风","wind5":"微风转北风3-4级","wind6":"北风3-4级","fx1":"微风","fx2":"微风","fl1":"小于3级","fl2":"小于3级","fl3":"小于3级","fl4":"小于3级","fl5":"小于3级转3-4级","fl6":"3-4级","index":"炎热","index_d":"天气炎热,建议着短衫、短裙、短裤、薄型T恤衫、敞领短袖棉衫等清凉夏季服装。","index48":"炎热","index48_d":"天气炎热,建议着短衫、短裙、短裤、薄型T恤衫、敞领短袖棉衫等清凉夏季服装。","index_uv":"很强","index48_uv":"强","index_xc":"适宜","index_tr":"适宜","index_co":"较不舒适","st1":"29","st2":"20","st3":"29","st4":"20","st5":"29","st6":"21","index_cl":"适宜","index_ls":"极适宜","index_ag":"易发"}}
取出:
city对应的值,即广州,temp1 到 temp3的值img1到img6的值求高手解答...
取出:
city对应的值,即广州,temp1 到 temp3的值img1到img6的值求高手解答...
JavaScriptSerializer jss = new JavaScriptSerializer();
List<info> lst = new List<info>();
info i = new info();
i.id = 0;
i.name = "张三";
i.sex = "男";
i.age = 20;
lst.Add(i);
string result = jss.Serialize(lst); //bead转json var tmp = jss.Deserialize<List<info>>(result); //json转bead
.NET 3.5
using System.Web.Script.Serialization;
demo:
public static XmlDocument SerializeXmlNode(string json)
{
json = json.Replace("<", "").Replace(">", "");
json = @"{
""?xml"": {
""@version"": ""1.0"",
""@standalone"": ""no""
},
""root"": " + json + @"
}"; XmlDocument doc;
try
{
doc = JsonConvert.DeserializeXmlNode(json);
}
catch
{
doc = new XmlDocument();
doc.AppendChild(doc.CreateElement("xml"));
}
return doc;
}
然后你就可以通过这种方式取出你想要的数值:weatherDescriptionInfo["weatherinfo"]["city"].ToString();当然这需要一个Newtonsoft.Json.dll。 你在网上找找。
并且支持linq
用法和js中json的用法差不多