我有一个JSON数据,看起来像这样:
{
"Item1": {
"Field1": "Val1",
"Field2": "Val2"
},
"Item2": {
"Field1": "Val11",
"Field2": "Val22"
},
....
"ItemN": {
"Field1": "Val1",
"Field2": "Val2"
},
}
我需要将它反序列化为一组类,看起来像这样:
public class Root
{
public Item Item1;
public Item Item2;
public List<Item> Items; // << all the Items should go here
}
public class Item
{
public string Field1;
public string Field2;
}
如何在反序列化时使Newtonsoft.Json按此方式映射数据?
Dictionary<string, Item>
。 - dbcList<Item>
,那么是否需要在某处捕获"ItemN"
名称,或者它们可以被丢弃? - dbc