Response DTOS doesnt show properties with null value

You can enable serializing null values globally by adding

JsConfig.IncludeNullValues = true

into Configure method or enabe serialization of null values for particular Dto by implementing RawSerializeFn and RawDeserializeFn:

JsConfig<Dto>.RawSerializeFn = (obj) =>
{
    using (JsConfig.With(includeNullValues: true))
    {
        return obj.ToJson();
    }
};

JsConfig<Dto>.RawDeserializeFn = (json) =>
{
    using (JsConfig.With(includeNullValues: true))
    {
        return JsonSerializer.DeserializeFromString<Dto>(json);
    }
};
1 Like