My goal is to serialize properties that don't have any attributes and properties which have a specific custom attribute.
For the following class:
public class Msg
{
public long Id { get; set; }
[CustomAttributeA]
public string Text { get; set; }
[CustomAttributeB]
public string Status { get; set; }
}
When I call a method Serialize(object, CustomAttributeA), I want to have the following output:
{
"Id" : someId,
"Text" : "some text"
}
And when I call Serialize(object, CustomAttributeB), I want to have following:
{
"Id" : someId,
"Status" : "some status"
}
I have read that it's possible to achieve this by creating a custom ContractResolver, but in this case must I create two separate contract resolvers?