Deserialize json array to c# list object
I am sure that exception is not related to you JSON string but try to remove bin
and obj
from solution folder and then clean and rebuild solution.
but after resolving that you will get the below exception
Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'namespace.Order' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.....
Because your JSON string is List of Order
so the deserialize would be change to :
List<Order> ObjOrderList = JsonConvert.DeserializeObject<List<Order>>(orderJson);
or in the other side you can also use JavaScriptSerializer
like:
Order[] orderList = new JavaScriptSerializer().Deserialize<Order[]>(orderJson);