I would like to use JsonIgnore to prevent the Social Security number from being serialized. However, using it prevents it from being passed into the Post method for the API. The value will be null. The API is using Newtonsoft for our deserialization/serialization. Right now I'm not using JsonIgnore and just filtering the SSN. Would like a more generalized approach to use on multiple fields that have sensitive data.
Asked
Active
Viewed 69 times
0
-
5Use different models for input and output data. – Guru Stron Oct 28 '21 at 14:43
-
You could exclude sensitive properties via a custom contract resolver, as shown in e.g. [Exclude property from serialization via custom attribute (json.net)](https://stackoverflow.com/q/13588022/3744182) and/or [Add a custom attribute to json.net](https://stackoverflow.com/q/32908592/3744182). Do either of those questions answer your question adequately also? – dbc Oct 28 '21 at 22:30
-
The following may be helpful: https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/object-oriented/inheritance – Tu deschizi eu inchid Oct 29 '21 at 04:10