相关疑难解决方法(0)

如何在JSON.NET中实现自定义JsonConverter来反序列化基类对象的列表?

我试图扩展这里给出的JSON.net示例 http://james.newtonking.com/projects/json/help/CustomCreationConverter.html

我有另一个派生自基类/接口的子类

public class Person
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

public class Employee : Person
{
    public string Department { get; set; }
    public string JobTitle { get; set; }
}

public class Artist : Person
{
    public string Skill { get; set; }
}

List<Person> people  = new List<Person>
{
    new Employee(),
    new Employee(),
    new Artist(),
};
Run Code Online (Sandbox Code Playgroud)

如何将Json反序列化回List <Person>

[
  {
    "Department": "Department1",
    "JobTitle": "JobTitle1",
    "FirstName": "FirstName1", …
Run Code Online (Sandbox Code Playgroud)

c# json json.net deserialization

292
推荐指数
6
解决办法
25万
查看次数

标签 统计

c# ×1

deserialization ×1

json ×1

json.net ×1