報(bào)錯(cuò)內(nèi)容 Newtonsoft.Json.JsonSerializationException:“Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'ConsoleApp_quhao.result' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly. To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array. Path 'data.results', line 1, position 115.” public class ResultClass { public string status { get; set; } public string code { get; set; } public string msg { get; set; } public Data data { get; set; } } public class Data { public condition condition { get; set; } public List<result> results { get; set; } 修改前: public result results { get; set; } } public class result { ..... } {"status":true,"code":0,"msg":"ok","data":{"condition":{"name":"石家莊市","children":0},"results":[{"code":"130100","parentcode":"130000","level":"2","name":"石家莊市","province":"河北省","city":"石家莊市","district":"","town":"","pinyin":"Shijiazhuang","jianpin":"SJZS","firstchar":"S","tel":"0311","zip":"050000","lng":"114.502461","lat":"38.045474"}]}} |
|