Is it possible to deserialize a JSON into a class where a property name could be one of two values?
For example both of these JSONs would deserialize into the same property:
var json1 = "{\"A\":5}";
var json2 = "{\"B\":5}";
I thought that maybe I could use the JsonPropertyName attribute twice.
[JsonPropertyName("A")]
[JsonPropertyName("B")]
public int SomeInt { get; set; }
This is not allowed.
Then I thought maybe if the deserializer could not find the JsonPropertyName attribute it would look for the actual property name.
[JsonPropertyName("A")]
public int B { get; set; }
But that doesn't work either.