I have a .net core 3.1 application. I use the library json.net (newtonsoft) to serialize or deserialize the json . This is the app settings for newtonsoft :
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers(options =>
{
options.SuppressAsyncSuffixInActionNames = false;
}).AddNewtonsoftJson(options =>
{
options.SerializerSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Local;
options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
options.SerializerSettings.Converters.Add(new GuidJsonConverter());
});
I've put this line to ignore null json value on deserialization :
options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
But I remark that it ignores also null value for serialization (when use Json method of the class Microsoft.AspNetCore.Mvc.Controller), but I don't want this behavior.
Is there a way to specify differents value of NullValueHandling for serialization and for deserialization ?