I'm trying to deserialize a JSON document like the following:
{
"items": {
"0": {
"name": "Item 1"
},
"1": {
"name": "Item 2"
}
}
}
Into an object like:
public class Inventory
{
public Item[] Items { get; set; }
}
public class Item
{
public string Name { get; set; }
}
The items
object should presumably be an array, however the data that I'm consuming uses an object, so I can always assume that they will be numeric values. What is the most efficient way to deserialize this? I am a Newtonsoft newbie and don't know where to start (should I extend a JsonConverter? Use a JsonTextReader directly?, something else?)