0

Is it possible to tell dynamically to ignore the property using JsonIgnore? As json message sometimes need to ignore a field. For example

Class A  {
[JsonProperty("Random1")]
public string somerandomfield1 {get; set;}
[JsonProperty("Random2")]
public string somerandomfield2 {get; set;}
}

However sometimes Class A needs to ignore field "somerandomfield1" while building a json message.

Class A {
[JsonIgnore]
public string somerandomfield1 {get; set;}
[JsonProperty("Random2")]
public string somerandomfield2 {get; set;}
}

1 Answer 1

1

Json.NET has the ability to conditionally serialize properties by placing a ShouldSerialize method on a class.

the following link will give details http://www.newtonsoft.com/json/help/html/conditionalproperties.htm

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.