Reputation: 6336
I have an existing class in an external assembly which I can't change. I would like to serialize an object from this class with Newtonsoft JSON.Net, but not all the properties.
Normally I can do this with the JsonIgnoreAttribute attribute like this:
public class TestJsonClass
{
public string PropA { get; set; }
[JsonIgnoreAttribute]
public string PropB { get; set; }
}
But since I can't change the class, is there a way to ignore a property without attributes?
Upvotes: 1
Views: 323
Reputation: 34
Try inherit class and override property with appropriate annotations or copy property values in a completely new class.
Upvotes: 1