We are following in .Net Core's path in transitioning from Newtonsoft.Json to the new System.Text.Json. One feature of Newtonsoft that we found convenient was to provide an error handler in the JsonSerializerSettings to log details which has greatly facilitated identifying and fixing serialization problems. As such:
jsonSerializerSettings = new JsonSerializerSettings()
{
Error = (sender, args) =>
{
logger.LogDebug($"JSON Parsing Error. Type={args.CurrentObject} Member={args.ErrorContext.Member} Path={args.ErrorContext.Path} Error={args.ErrorContext.Error.Message}");
}
};
Is anyone aware of an equivalent behavior that could be configured for System.Text.Json?