且构网

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

无法反序列化当前的 JSON 数组(例如 [1,2,3]).C#,无法找出错误

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

您的 JSON 实体是一个数组而不是单个对象.这就是 JSON.NET 为你的反序列化而哭泣的原因!

Your JSON entity is an array rather than a single object. This is why JSON.NET is crying about your deserialization!

将此 JSON 反序列化为 IEnumerable,您将解决您的问题:

Deserialize this JSON as an IEnumerable<T> and you'll solve your issue:

IEnumerable<CardSet> result = JsonConvert.DeserializeObject<IEnumerable<CardSet>>(jsonText);