ServiceStack 3.9.43 JsonSerializer:IncludeNull对序列化没有影响?

时间:2013-04-26 14:30:59

标签: servicestack jsonserializer

在AppHost中

public override void Configure(Funq.Container container)
{
    JsConfig.IncludeNullValues = true;

    SetConfig(new EndpointHostConfig
    {
        ServiceStackHandlerFactoryPath = "api",
        DefaultContentType = ServiceStack.Common.Web.ContentType.Json,
        DefaultJsonpCacheExpiration = new TimeSpan(0, 0, 0, 0),
        GlobalResponseHeaders = { { "Cache-Control", "no-cache" } },
    });
...

当我执行Dto.ToJson()时,空字段根本没有被序列化。发现这是因为我的服务引发了序列化错误。

0 个答案:

没有答案