c# Deserialize JSON list of object error

倾然丶 夕夏残阳落幕 提交于 2019-12-02 04:28:25

I would suggest doing something like this:

    People persons = new People(new JavaScriptSerializer().Deserialize<IList<Person>>(json));

and changing your constructor to this:

    public People(IEnumerable<Person> collection) : base(collection)
    {

    }

You don't have to worry about messy casts between types, and it works just as well since your People class has a base constructor that takes in an IEnumberable.

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