According to the documentation: “The JSON/JSV and CSV serialization can be customized globally by configuring the JsConfig or type-specific JsConfig static classes with your preferred defaults.” changing JsConfig should impact TypeSerializer behavior also, but it seems that setting IncludeNullValues / IncludeNullValuesInDictionaries does not change the resulting Jsv.
My example:
static void Main(string[] args)
{
var dict = new Dictionary<string, string>
{
{ “key1”, “value1” },
{ “key2”, null }
};
Console.WriteLine($"Jsv without config : {TypeSerializer.SerializeToString(dict)}");
Console.WriteLine($"Json without config : {JsonSerializer.SerializeToString(dict)}");
using (JsConfig.With(new Config
{
IncludeNullValues = true, // not really needed
IncludeNullValuesInDictionaries = true
}))
{
Console.WriteLine($"Jsv with config : {TypeSerializer.SerializeToString(dict)}");
Console.WriteLine($"Json with config : {JsonSerializer.SerializeToString(dict)}");
}
}
produces jsv without the key-value where value = null, while json has the entry:
Jsv without config : {key1:value1}
Json without config : {“key1”:“value1”}
Jsv with config : {key1:value1}
Json with config : {“key1”:“value1”,“key2”:null}
Am I missing something here or is this normal behavior for jsv serialization?
Many thanks for your answer, best regards!