This is my json
{
"odata.metadata" : "",
"value" : [
{
"ItemCode" : "NUOVO_ELEMENT1406",
"ItemName" : "Prova3",
"QuantityOnStock" : 0.0
},
{
"ItemCode" : "NUOVO_ELEMENT14506",
"ItemName" : "Prova3",
"QuantityOnStock" : 0.0
},
{
"ItemCode" : "NUOVO_ELEMENT1455106",
"ItemName" : "Prova3",
"QuantityOnStock" : 0.0
},
{
"ItemCode" : "NUOVO_ELEMENT1455a106",
"ItemName" : "Prova3",
"QuantityOnStock" : 0.0
},
{
"ItemCode" : "NUOVO_ELEMENT145574a106",
"ItemName" : "Prova3",
"QuantityOnStock" : 0.0
},
{
"ItemCode" : "NUOVO_ELEMENT16",
"ItemName" : "Prova3",
"QuantityOnStock" : 0.0
},
{
"ItemCode" : "NUOVO_ELEMENT1d6",
"ItemName" : "Prova3",
"QuantityOnStock" : 0.0
},
{
"ItemCode" : "NUOVO_ELEMENT433",
"ItemName" : "Prova3",
"QuantityOnStock" : 0.0
},
{
"ItemCode" : "NUOVO_ELEMENT1d464645454546",
"ItemName" : "UPDATE",
"QuantityOnStock" : 0.0
},
{
"ItemCode" : "NUOVO_ELEMENT433787079",
"ItemName" : "Prova3",
"QuantityOnStock" : 0.0
},
{
"ItemCode" : "NUOVO_ELEMENT43389898989787079",
"ItemName" : "Prova3121",
"QuantityOnStock" : 0.0
}
]
}
this is Entity which has the task of mapping the json
public class Item
{
[JsonProperty(PropertyName ="ItemCode")]
public string ItemCode { get; set; }
[JsonProperty(PropertyName ="ItemName")]
public string ItemName { get; set; }
[JsonProperty(PropertyName ="QuantityOnStock")]
public decimal QuantityOnStock { get; set; }
}
With this class, I thought of the json
internal class JsonParser
{
internal void Deserialize(string v)
{
List<Item> it = JsonConvert.DeserializeObject<List<Item>>(v);
foreach (Item item in it)
{
Console.WriteLine("{0},{1}", item.ItemName, item.ItemCode);
}
}
}
I tried to remove List and use only Item, if my json contains only one element of course no problem, but in cases where I have more elements and I try to use the List I receive the error described in the title.

Itemobjects is within thevalueproperty in the JSON. So you either need to target that specifically for your deserialisation, or use a wrapper class to represent the object which encloses the array and deserialise to that. e.g.public class SomeClass { public List<Item> value { get; set; }etcDeserialize()method. It will work fine with this input[{ItemCode:'ItemCode1',ItemName:'ItemName1',QuantityOnStock:'10.25'},{ItemCode:'ItemCode2',ItemName:'ItemName2',QuantityOnStock:'10.25'}]