I'm using System.Web.Script.Serialization.JavaScriptSerializer to serialize an object to JSON, but there are some fields within the object which don't need to be serialized. In java I would mark them with the 'transient' keyword. Is there an equivalent keyword or standard practice in C#?
Put [ScriptIgnore]
attribute on the property and it will not be serialized.
See: ScriptIgnoreAttribute Class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With