string url ="http://api.map.baidu.com/telematics/v3/weather?location=昌图&output=json&ak=************";
WebClient wc =newWebClient();
wc.Encoding=Encoding.UTF8;
var txt = wc.DownloadString(url);
var xx =JsonConvert.DeserializeObject<BaiduWeather>(txt);
publicclassIndex
{
publicstringTitle{ get;set;}
publicstringZs{ get;set;}
publicstringTipt{ get;set;}
publicstringDes{ get;set;}
}
publicclassWeather_data
{
publicstringDate{ get;set;}
publicstringDayPictureUrl{ get;set;}
publicstringNightPictureUrl{ get;set;}
publicstringWeather{ get;set;}
publicstringWind{ get;set;}
publicstringTemperature{ get;set;}
}
publicclassResults
{
publicstringCurrentCity{ get;set;}
publicstringPm25{ get;set;}
publicList<Index>Index{ get;set;}
publicList<Weather_data>Weather_data{ get;set;}
}
publicclassBaiduWeather
{
publicintError{ get;set;}
publicstringStatus{ get;set;}
publicDateTimeDate{ get;set;}
publicList<Results>Results{ get;set;}
}
时间: 2024-11-29 01:18:41