I have a DTO class which I Serialize
Json.Serialize(MyClass)
How can I exclude a public property of it?
(It has to be public, as I use it in my code somewhere else)
cjson
I have a DTO class which I Serialize
Json.Serialize(MyClass)
How can I exclude a public property of it?
(It has to be public, as I use it in my code somewhere else)
Best Answer
If you are using Json.Net attribute
[JsonIgnore]
will simply ignore the field/property while serializing or deserialising.Or you can use DataContract and DataMember attribute to selectively serialize/deserialize properties/fields.
Refer http://james.newtonking.com/archive/2009/10/23/efficient-json-with-json-net-reducing-serialized-json-size for more details