xxxxxxxxxx
[JsonProperty(NullValueHandling=NullValueHandling.Ignore)]
// or
[JsonProperty("property_name", NullValueHandling=NullValueHandling.Ignore)]
// or for all properties in a class
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
xxxxxxxxxx
// Temporary file
var jsonTempFilePath = FileUtils.CreateTmpFile();
using (var fs = File.Open(jsonTempFilePath, FileMode.Open))
using (var sw = new StreamWriter(fs))
using (var jw = new JsonTextWriter(sw))
{
var serializer = new JsonSerializer()
{
// Ignore null properties
NullValueHandling = NullValueHandling.Ignore,
};
serializer.Serialize(jw, output);
}