Json ,net is not working

2020-07-08 06:09发布

问题:

I am trying to parse an with json net in c#. And i am using json .net

But it is showing the following exception

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

i am creating json string with jquery. And the example of string is as follows.

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

回答1:

The JSON document represents an object (JObject) with the keys "0" and "1". It is not a true array, but rather an object that somewhat mimics an array.

Either read the document as an object, or fix the document to be a real array:

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


标签: c# json