[英]JIL json serializer does not serialize properties from derived class
JIL json serializer does not serialize properties from derived class JIL json序列化程序不会序列化派生类的属性
Below are the code snippet: 下面是代码片段:
public async Task WriteAsync(OutputFormatterWriteContext context)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
var response = context.HttpContext.Response; response.ContentType = "application/json";
using (var writer = context.WriterFactory(response.Body, Encoding.UTF8))
{
Jil.JSON.Serialize(context.Object, writer);
await writer.FlushAsync();
}
}
1) Model Type: 1)型号:
public class BaseBOResponse
{
public string pk { get; set; }
}
public class PaymentTypeBOResponse : BaseBOResponse
{
public string description { get; set; }
public bool isSystem { get; set; }
public bool isActive { get; set; }
}
Here when i set something to BaseBOResponse's response property "pk", then JIL serializer eliminate this property. 在这里,当我将某些内容设置为BaseBOResponse的响应属性“ pk”时,JIL序列化程序将消除此属性。
Please suggest if you have any solution. 请提出您是否有解决方案。
您必须告诉Jil也包括继承的属性:
Jil.JSON.Serialize(context.Object, writer, Jil.Options.IncludeInherited);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.