We have N number of JSON parameters and class properties as well but have to remove dynamically the JSON parameters which are not available in class properties while serializing.
If I use [JsonIgnore]
it is only removing values, not the entire property; we need to remove the entire property.
Example:
JSON request:
{
"Name":"ABC",
"Age":26,
"Designation":"Er",
"Place":"Pune",
"Gender":"Male"
}
Class:
[Serializable]
public class SampleProperties
{
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("Age")]
public int Age { get; set; }
[JsonProperty("Designation")]
public string Designation { get; set; }
}
Result Expecting :
{
"Name":"ABC",
"Age":26,
"Designation":"Er"
}