[英]JIL json serializer does not serialize properties from derived class
JIL json序列化程序不會序列化派生類的屬性
下面是代碼片段:
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)型號:
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; }
}
在這里,當我將某些內容設置為BaseBOResponse的響應屬性“ pk”時,JIL序列化程序將消除此屬性。
請提出您是否有解決方案。
您必須告訴Jil也包括繼承的屬性:
Jil.JSON.Serialize(context.Object, writer, Jil.Options.IncludeInherited);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.