How to deserialize variable size JSON string with variable names

强颜欢笑 提交于 2019-12-06 22:53:28

You can do this probably more simply than you think.. your ?????? class can be anything..

public class GenericObject
{
    public int field_id1  {get;set;}
    public int field_id2  {get;set;}
    public int field_id3  {get;set;}
    public string field_id4 {get;set;}
}

and then deserialize the root of the object graph into an object that contains a Dictionary<string,GenericObject>...

public class SomeContainer
{
    public Dictionary<string,GenericObject> container {get;set;}
}

you can then loop over the values of the dictionary if you don't care about the names of the keys.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!