json.net (newtonsoft)
I am looking through the documentation but I can't find anything on this or the best way to do it.

public class Base
{
    public string Name;
}
public class Derived : Base
{
    public string Something;
}

JsonConvert.Deserialize<List<Base>>(text);

现在我在序列化列表中有了派生对象.如何反序列化列表并返回派生类型?

推荐答案

If you are storing the type in your text (as you should be in this scenario), you can use the JsonSerializerSettings.

请参阅:how to deserialize JSON into IEnumerable<BaseType> with Newtonsoft JSON.NET

Be careful, though.使用TypeNameHandling = TypeNameHandling.None以外的任何东西都可能会使您最多使用a security vulnerability.

Json相关问答推荐

2020-12年草案中的Json列举模式

如何在PowerShell中扩展JSON中的嵌套数组

为什么JQ筛选器不将原始输入打印为$var|.';文档?

在MongoDB中检索某个月份和年份的JSON文档

Azure数据工厂-WEB活动输出赢得';t返回JSON

如何在VB6中将字符串转换或解码为可读格式?

如何避免解析 ISuperObject 类型字段中的 json 对象

如何使用 JOLT 使用输入数组中的值和层次 struct 中的其他字段创建数组

使用 Redis 作为键值存储

展平多个数组以保持顺序

使用 jq 工具将文本从 txt 文件转换为 json

在这种情况下我如何实现 UnmarshalJSON 并且只为一个接口字段定义特殊行为?

无法在Kotlin 中解析JSONObject

为什么JsonConvert反序列化对象以int但不长失败

解析 JSON API 响应

Laravel5 Json 获取文件内容

如何使用 Jackson 重命名 JSON 序列化中的根键

使用 jq 如何用其他名称替换键的名称

在 React 中访问子级的父级状态

如何从 MySQL 中检索 JSON 数据?