且构网

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

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

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

您的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<T>,您将解决问题:

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

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