How can I conditionally serialize some variables of a class in C# using system.text.json.
Earlier I was using shouldserialize keyword in newtonsoft json. But now i am supposed to move everything to text.json.
Is there alternative to shouldserialize keyword in here?
I tried many things like for a variable setter{return null} when condition occur ,then using jsonignore to ignore null.
But this thing doesn’t work on Byte ,Word , Dword like .
Please guide me how can i ignore some variables of my object when serializing into json. Lets say when bool read is true ,i need specific set of vars and when not then others.
Shivam Pandey is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.