Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Json ,net is not working

Tags:

json

c#

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"}}
like image 341
ap.singh Avatar asked Aug 21 '13 17:08

ap.singh


1 Answers

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"}]
like image 178
cdhowie Avatar answered Sep 28 '22 10:09

cdhowie