3

If I have an object that I return from WebApi, is it possible to mark one of the properties as hidden ?

1 Answer 1

7

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.