Reputation: 7934
If I have an object that I return from WebApi, is it possible to mark one of the properties as hidden ?
Upvotes: 3
Views: 2836
Reputation: 667
You can use:
[JsonIgnore]
[XmlIgnore]
These will hide your property from both kinds of serialization.
I have always tried to mix both in a single class but JSonIgnoreAtrribute
is a sealed class and does not leave us with a seamless integration option.
So the straight forward way is to add both attributes on your ignorable property.
Upvotes: 7