如果object为null,则服务堆栈返回
{}
但我想返回null值,我怎么能实现呢?
我的序列化代码:
public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, System.Net.Http.HttpContent content, TransportContext transportContext)
{
var task = Task.Factory.StartNew(() => JsonSerializer.SerializeToStream(value, type, writeStream));
return task;
}
答案 0 :(得分:3)
在AppHost中添加全局配置:
JsConfig.IncludeNullValues = true;