如何解析天气的json
{"weatherinfo":{"city":"上海","cityid":"101020100","temp1":"10℃","temp2":"6℃","weather"...
{"weatherinfo":{"city":"上海","cityid":"101020100","temp1":"10℃","temp2":"6℃","weather":"晴转多云","img1":"d0.gif","img2":"n1.gif","ptime":"11:00"}}
asp.net 展开
asp.net 展开
2个回答
展开全部
是在c#后台得到这个字符串的吗?
如果是的话 新建一个类weatherinfo
public class weatherinfo
{
public string city { get; set; }
public string cityid { get; set; }
public string temp1 { get; set; }
public string temp2 { get; set; }
public string weather { get; set; }
public string img1 { get; set; }
public string img2 { get; set; }
public string ptime { get; set; }
}
在后台 这样使用
weatherinfo model= JsonConvert.DeserializeObject<weatherinfo>("这里是你的JSON");//JSON转为对象
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询