最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

newtonsoft.json解析天氣數(shù)據(jù)出錯(cuò)解決方法

 更新時(shí)間:2014年02月25日 11:33:39   作者:  
這篇文章主要介紹了NewtonSoft.JSon解析天氣數(shù)據(jù)時(shí)出錯(cuò)的解決方法,需要的朋友可以參考下

今天用NewtonSoft.JSon解析一個(gè)天氣數(shù)據(jù),數(shù)據(jù)格式如:

復(fù)制代碼 代碼如下:

{"status":1,"detail":"\u6570\u636e\u83b7\u53d6\u6210\u529f","data":[[{"date":"2014-01-01","dis_id":"1119","dis_name":"\u5f90\u5dde\u5e02","url":"http:\/\/www.tianqiyubao.com\/local.php?dis_id=1119","weather":"1","wind":"\u897f\u98ce3-4\u7ea7","weather_name":"\u6674","weather_pic":"styles\/images\/icon2\/day\/1.png","humidity":"","tem_min":"1","tem_max":"13","sunrise":"07:17","sunset":"17:12","pm":"109","air":"\u826f","day_night":[{"date":"2014-01-01","dis_id":"1119","dis_name":"\u5f90\u5dde\u5e02","url":"http:\/\/www.tianqiyubao.com\/local.php?dis_id=1119","weather":"1","wind":"\u897f\u98ce3-4\u7ea7","weather_name":"\u6674","weather_pic":"styles\/images\/icon2\/day\/1.png","humidity":"","tem":"13"},{"date":"2014-01-01","dis_id":"1119","dis_name":"\u5f90\u5dde\u5e02","url":"http:\/\/www.tianqiyubao.com\/local.php?dis_id=1119","weather":"1","wind":"\u5317\u98ce3-4\u7ea7","weather_name":"\u6674","weather_pic":"styles\/images\/icon2\/night\/1.png","humidity":"","tem":"1"}]}]]}

結(jié)果就老報(bào)一個(gè)錯(cuò)誤。

復(fù)制代碼 代碼如下:

Cannot deserialize JSON array (i.e. [1,2,3]) into type 'SweetWeather.MoreDayWeatherInfoFullDay'.
The deserialized type must be an array or implement a collection interface like IEnumerable, ICollection or IList.
To force JSON arrays to deserialize add the JsonArrayAttribute to the type. Path 'data[0]', line 1, position 69.

最后還是報(bào)錯(cuò)。仔細(xì)發(fā)現(xiàn)有兩個(gè)方框號(hào),原來是自己實(shí)體類的設(shè)計(jì)有問題,

原實(shí)體類:

復(fù)制代碼 代碼如下:

public string status { get; set; }
public string detail { get; set; }
public List<MoreDayWeatherInfoFullDay> data { get; set;

更正后的實(shí)體類:

復(fù)制代碼 代碼如下:

public string status { get; set; }
public string detail { get; set; }
public List<List<MoreDayWeatherInfoFullDay>> data { get; set; }

正確無誤了。

相關(guān)文章

最新評論

建宁县| 布拖县| 隆子县| 从江县| 阿鲁科尔沁旗| 江门市| 武鸣县| 社旗县| 双城市| 游戏| 阳信县| 鹤峰县| 随州市| 衡山县| 资中县| 昌乐县| 桑植县| 西吉县| 剑阁县| 永嘉县| 乌恰县| 闽清县| 五常市| 富源县| 平潭县| 连平县| 南宁市| 都昌县| 黄大仙区| 麻城市| 加查县| 临澧县| 台州市| 南和县| 朝阳县| 连平县| 定南县| 通海县| 梨树县| 阿坝县| 静乐县|