8

我正在尝试在 c# 中解析一个 with json net。我正在使用 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"}}
4

1 回答 1

12

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

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

[{"tyreId":"","tyreNum":"dsf","tyreSecondHand":"false","tyreReplace":"true"},{"tyreId":"","tyreNum":"gfd","tyreSecondHand":"true","tyreReplace":"true"}]
于 2013-08-21T17:33:47.523 回答