In my Startup.cs
i have set up my default serializer with options like this
.AddNewtonsoftJson(options =>
{
options.UseMemberCasing();
options.SerializerSettings.DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat;
options.SerializerSettings.FloatParseHandling = Newtonsoft.Json.FloatParseHandling.Double;
options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
options.SerializerSettings.TraceWriter = new NLogTraceWriter();
options.SerializerSettings.Culture = CultureInfo.InvariantCulture;
JsonConvert.DefaultSettings = () => options.SerializerSettings;
});
and expected anything returned from Action or coming to Action as a parameter to be serialized (or deserialized) using this setting, which is not the case. This setting only gets used when i explicitly use JsonConvert.SerializeObject()
or JsonConvert.DeserializeObject()
method. Is there anything else I need to set up so I don't have to use these functions explicitly in every action?
Can anyone please enlighten me on what am I doing wrong?