'Newtonsoft.Json.JsonConvert how to redact values?

I want to log the serialized string but it is a sensitive data.

I only need to log property names, not values for example if I get a null reference error, I only need to know which property exist in the object. I actually use the original object to get a PDF from a PDF template.

I need to redact strings, integers etc but not the lists or arrays etc. so the serializer should be responsible to do this redacting.

Is there any way to achieve this in Newtonsoft.Json.JsonConvert

Of course i dont need to deserialize the object later.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source