且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将嵌套的 JSON 反序列化为 C# 对象

更新时间:2023-02-17 19:37:34

"Items"使用Dictionary>,即:

class Response
{
    public Dictionary<string, List<Info>> Items { get; set; }
    public string[] Errors { get; set; }
}

class Info
{
    public string Prop1 { get; set; }
    public string Prop2 { get; set; }
    public int Prop3 { get; set; }
    public bool Prop4 { get; set; }
}

这假定项目名称 "Item322A""Item2B" 会因响应而异,并将这些名称作为字典键读取.

This assumes that the item names "Item322A" and "Item2B" will vary from response to response, and reads these names in as the dictionary keys.

示例小提琴.