8

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"}}
ap.singh
  • 1,150
  • 4
  • 15
  • 35

1 Answers1

12

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"}]
cdhowie
  • 158,093
  • 24
  • 286
  • 300