Suppose I have the following classes:
public class SomeBase
{
}
public class ACommon : SomeBase
{
[IsInput, IsOutput, IsInternal]
public int AInput1 { get; set; }
[IsOutput, IsInternal]
public int AOutput1 { get; set; }
[IsInternal]
public int AInternal1 { get; set; }
[IsOutput, IsInternal]
public new BCommon ARefToB { get; set; }
}
public class BCommon : SomeBase
{
[IsInput, IsOutput, IsInternal]
public int BInput1 { get; set; }
[IsOutput, IsInternal]
public int BOutput1 { get; set; }
[IsInternal]
public int BInternal1 { get; set; }
}
Let's say I have the following JSON describing an ACommon object:
"{\"AInput1\":1,\"AOutput1\":2,\"AInternal1\":3,\"ARefToB\":{\"BInput1\":11,\"BOutput1\":12,\"BInternal1\":13}}"
I would like to be able to deserialize this string 3 different ways:
- All properties are deserialized
- All properties with IsInternal attribute are set to some custom value
- All properties with IsInternal or IsOutput attribute are set to some custom value
So, for example, when I deserialize with the third option, my objects would look like:
A.AInput = 1
A.AOutput1 = -1
A.AInternal1 = -1
A.ARefToB.BInput1 = 11
A.ARefToB.BOutput1 = -1
A.ARefToB.BInternal1 = -1
I've been looking into using a custom converter, but haven't had success yet in recursively converting every object within the parent object in the same way.