且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法将 JSON 数组(例如 [1,2,3])反序列化为类型“",因为类型需要 JSON 对象(例如 {“name":“value"})才能正确反序列化

更新时间:2021-09-15 21:59:14

您的 json 字符串包含在方括号 ([]) 中,因此它被解释为数组而不是单个 RetrieveMultipleResponse 对象.因此,您需要将其反序列化为 RetrieveMultipleResponse 的类型集合,例如:

Your json string is wrapped within square brackets ([]), hence it is interpreted as array instead of single RetrieveMultipleResponse object. Therefore, you need to deserialize it to type collection of RetrieveMultipleResponse, for example :

var objResponse1 = 
    JsonConvert.DeserializeObject<List<RetrieveMultipleResponse>>(JsonStr);