杰森,网络坏了

本文关键字:坏了 网络 杰森 | 更新日期: 2023-09-27 18:28:34

我正在尝试在c#中解析一个带有json的网络。我正在使用json.net

但它显示了以下异常

Error reading JArray from JsonReader. Current JsonReader item is not an array: StartObject. Path '', line 1, position 1.

我正在用jquery创建json字符串。字符串的例子如下。

 {"0":{"tyreId":"","tyreNum":"dsf","tyreSecondHand":"false","tyreReplace":"true"},"1":{"tyreId":"","tyreNum":"gfd","tyreSecondHand":"true","tyreReplace":"true"}}

杰森,网络坏了

JSON文档表示一个具有关键字"0""1"的对象(JObject)。它不是一个真正的数组,而是一个在某种程度上模仿数组的对象。

要么将文档作为对象读取,要么将文档固定为真实数组:

[{"tyreId":"","tyreNum":"dsf","tyreSecondHand":"false","tyreReplace":"true"},{"tyreId":"","tyreNum":"gfd","tyreSecondHand":"true","tyreReplace":"true"}]