There is a Dictionary where some values are primitive boxed values (bool, int, decimal) and others are null and DBNull.Value. Is it possible to output serialized JSON with undefined keyword for the latter category of entries using JSON.NET?
I was trying to set NullValueHandling.Ignore but that removes null-ed property completely. An implementation of JsonConverter does not help as it is not used on null value.
To illustrate my question consider this object
var toSerialize = new Dictionary<string, object> =
{
{"key1": 1},
{"key2": true},
{"key3": DBNull.Value},
{"key4": null}
};
The result should be as
{
"key1": 1,
"key2": true,
"key3": undefined,
"key4": undefined
}
and not as
{
"key1": 1,
"key2": true,
"key3": null,
"key4": null
}
the indentation is not important. Thanks.