I am using Newtonsoft's JsonSerializer to serialise some classes.
As I wanted to omit one field of my class in the serialisation process, I declared it as follow:
[JsonIgnore]
public int ParentId { get; set; }
This worked, but I am now facing a new problem : In a derived class, I would like this field to appear (and do so only in this specific derived class).
I have been looking through the documentation and on the Internet for a way to override this setting in child classes (I guess I need something like [JsonStopIgnore]
, but I couldn't find anything close).
- Is there any way for me to force
JsonSerializer
to pick up again this attribute ? - Is it possible to explicitly mark an attribute as
[JsonIgnore]
, but only in base class ?