|
100鱼币
求助,C# 处理json数据报错
这是闲的没事想用unity做一个天气预报的APP
在访问这个网址的时候出了一些问题
返回的JSON 数据是这样的
- {
- "success": "1",
- "result": [
- {
- "weaid": "1",
- "days": "2019-05-26",
- "week": "星期日",
- "cityno": "beijing",
- "citynm": "北京",
- "cityid": "101010100",
- "temperature": "16",
- "humidity": "0%/0%",
- "weather": "晴",
- "weather_icon": "http://api.k780.com/upload/weather/d/0.gif",
- "weather_icon1": "http://api.k780.com/upload/weather/n/0.gif",
- "wind": "北风",
- "winp": "4-5级",
- "temp_high": "16",
- "temp_low": "16",
- "humi_high": "0",
- "humi_low": "0",
- "weatid": "1",
- "weatid1": "1",
- "windid": "8",
- "winpid": "2",
- "weather_iconid": "0",
- "weather_iconid1": "0"
- },
- {
- "weaid": "1",
- "days": "2019-05-27",
- "week": "星期一",
- "cityno": "beijing",
- "citynm": "北京",
- "cityid": "101010100",
- "temperature": "29℃/15℃",
- "humidity": "0%/0%",
- "weather": "晴",
- "weather_icon": "http://api.k780.com/upload/weather/d/0.gif",
- "weather_icon1": "http://api.k780.com/upload/weather/n/0.gif",
- "wind": "北风转西风",
- "winp": "3-4级转3-4级",
- "temp_high": "29",
- "temp_low": "15",
- "humi_high": "0",
- "humi_low": "0",
- "weatid": "1",
- "weatid1": "1",
- "windid": "8",
- "winpid": "1",
- "weather_iconid": "0",
- "weather_iconid1": "0"
- },
- {
- "weaid": "1",
- "days": "2019-05-28",
- "week": "星期二",
- "cityno": "beijing",
- "citynm": "北京",
- "cityid": "101010100",
- "temperature": "32℃/17℃",
- "humidity": "0%/0%",
- "weather": "晴",
- "weather_icon": "http://api.k780.com/upload/weather/d/0.gif",
- "weather_icon1": "http://api.k780.com/upload/weather/n/0.gif",
- "wind": "西南风",
- "winp": "3-4级转3-4级",
- "temp_high": "32",
- "temp_low": "17",
- "humi_high": "0",
- "humi_low": "0",
- "weatid": "1",
- "weatid1": "1",
- "windid": "5",
- "winpid": "1",
- "weather_iconid": "0",
- "weather_iconid1": "0"
- },
- {
- "weaid": "1",
- "days": "2019-05-29",
- "week": "星期三",
- "cityno": "beijing",
- "citynm": "北京",
- "cityid": "101010100",
- "temperature": "33℃/21℃",
- "humidity": "0%/0%",
- "weather": "晴转多云",
- "weather_icon": "http://api.k780.com/upload/weather/d/0.gif",
- "weather_icon1": "http://api.k780.com/upload/weather/n/1.gif",
- "wind": "南风转西南风",
- "winp": "小于3级转小于3级",
- "temp_high": "33",
- "temp_low": "21",
- "humi_high": "0",
- "humi_low": "0",
- "weatid": "1",
- "weatid1": "2",
- "windid": "4",
- "winpid": "0",
- "weather_iconid": "0",
- "weather_iconid1": "1"
- },
- {
- "weaid": "1",
- "days": "2019-05-30",
- "week": "星期四",
- "cityno": "beijing",
- "citynm": "北京",
- "cityid": "101010100",
- "temperature": "32℃/17℃",
- "humidity": "0%/0%",
- "weather": "多云转晴",
- "weather_icon": "http://api.k780.com/upload/weather/d/1.gif",
- "weather_icon1": "http://api.k780.com/upload/weather/n/0.gif",
- "wind": "西北风转北风",
- "winp": "4-5级转4-5级",
- "temp_high": "32",
- "temp_low": "17",
- "humi_high": "0",
- "humi_low": "0",
- "weatid": "2",
- "weatid1": "1",
- "windid": "7",
- "winpid": "2",
- "weather_iconid": "1",
- "weather_iconid1": "0"
- },
- {
- "weaid": "1",
- "days": "2019-05-31",
- "week": "星期五",
- "cityno": "beijing",
- "citynm": "北京",
- "cityid": "101010100",
- "temperature": "31℃/16℃",
- "humidity": "0%/0%",
- "weather": "晴",
- "weather_icon": "http://api.k780.com/upload/weather/d/0.gif",
- "weather_icon1": "http://api.k780.com/upload/weather/n/0.gif",
- "wind": "西南风",
- "winp": "小于3级",
- "temp_high": "31",
- "temp_low": "16",
- "humi_high": "0",
- "humi_low": "0",
- "weatid": "1",
- "weatid1": "1",
- "windid": "5",
- "winpid": "0",
- "weather_iconid": "0",
- "weather_iconid1": "0"
- },
- {
- "weaid": "1",
- "days": "2019-06-01",
- "week": "星期六",
- "cityno": "beijing",
- "citynm": "北京",
- "cityid": "101010100",
- "temperature": "34℃/19℃",
- "humidity": "0%/0%",
- "weather": "晴",
- "weather_icon": "http://api.k780.com/upload/weather/d/0.gif",
- "weather_icon1": "http://api.k780.com/upload/weather/n/0.gif",
- "wind": "西南风",
- "winp": "3-4级转3-4级",
- "temp_high": "34",
- "temp_low": "19",
- "humi_high": "0",
- "humi_low": "0",
- "weatid": "1",
- "weatid1": "1",
- "windid": "5",
- "winpid": "1",
- "weather_iconid": "0",
- "weather_iconid1": "0"
- }
- ]
- }
复制代码
我使用了生成c#实体类
但是在使用以下代码转成 List<> 的时候就报错了
- var urladdress = "http://api.k780.com/?app=weather.future&weaid=1&appkey=42738&sign=8d01f34cb90f27f9f26a2bc6dce6fae5&format=json";
- Debug.Log("click");
- var data_weather = GetWebClient(urladdress);
- //Debug.Log(data_weather);
- List<Root> jobInfoList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Root>>(data_weather);
复制代码
报错在 DeserializeObject
报错的提示是:
- JsonSerializationException: Cannot deserialize JSON object into type 'System.Collections.Generic.List`1[updateurl+Root]'.
复制代码
不清楚是什么原因啊?
求指导!
是因为我没有对JSON 进行转义吗?
下面附项目源码
|
|