JSON字符串{"geonames":[{"continent":"EU","capital":"Andorra la Vella","languages":"ca","geonameId":3041565,"south":42.42849259876837,"isoAlpha3":"AND","north":42.65604389629997,"fipsCode":"AN","population":"84000","east":1.7865427778319827,"isoNumeric":"020","areaInSqKm":"468.0","countryCode":"AD","west":1.4071867141112762,"countryName":"Andorra","continentName":"Europe","currencyCode":"EUR"},{"continent":"AS","capital":"Abu Dhabi","languages":"ar-AE,fa,en,hi,ur","geonameId":290557,"south":22.633329391479492,"isoAlpha3":"ARE","north":26.08415985107422,"fipsCode":"AE","population":"4975593","east":56.38166046142578,"isoNumeric":"784","areaInSqKm":"82880.0","countryCode":"AE","west":51.58332824707031,"countryName":"United Arab Emirates","continentName":"Asia","currencyCode":"AED"},{"continent":"AS","capital":"Kabul","languages":"fa-AF,ps,uz-AF,tk","geonameId":1149361,"south":29.377472,"isoAlpha3":"AFG","north":38.483418,"fipsCode":"AF","population":"29121286","east":74.879448,"isoNumeric":"004","areaInSqKm":"647500.0","countryCode":"AF","west":60.478443,"countryName":"Afghanistan","continentName":"Asia","currencyCode":"AFN"},{"continent":"AF","capital":"Harare","languages":"en-ZW,sn,nr,nd","geonameId":878675,"south":-22.417738,"isoAlpha3":"ZWE","north":-15.608835,"fipsCode":"ZI","population":"13061000","east":33.056305,"isoNumeric":"716","areaInSqKm":"390580.0","countryCode":"ZW","west":25.237028,"countryName":"Zimbabwe","continentName":"Africa","currencyCode":"ZWL"}]}如何強(qiáng)制 Newtonsoft 解析數(shù)據(jù)?異常 Newtonsoft.Json.JsonSerializationException:'無法將當(dāng)前 JSON 數(shù)組(例如 [1,2,3])反序列化為類型'App.Geonames',因?yàn)樵擃愋托枰粋€(gè) JSON 對(duì)象(例如 {"name":"value"})正確反序列化。要修復(fù)此錯(cuò)誤,請(qǐng)將 JSON 更改為 JSON 對(duì)象(例如 {"name":"value"})或?qū)⒎葱蛄谢愋透臑閿?shù)組或?qū)崿F(xiàn)集合接口的類型(例如 ICollection、IList),例如可以從 JSON 數(shù)組反序列化。JsonArrayAttribute 也可以添加到類型中以強(qiáng)制它從 JSON 數(shù)組反序列化。
- 2 回答
- 0 關(guān)注
- 178 瀏覽
添加回答
舉報(bào)
0/150
提交
取消