First of all; I'm using Newtonsoft.Json to deserialize JSON into objects like this:
JSON:
[{"number":22041}]
Order Object
[JsonProperty("number")]
public string OrderNumber { get; set; }
However, depending on which version the 'other' side is on, the Json may change into
[{"order_number":22041}]
So I'd actually like to pre-define "number" and "order_number" to both deserialize into my OrderNumber.
Is there a way to achieve something like the following (that actually works)
[JsonProperty("order_number")]
[JsonProperty("number")]
public string OrderNumber { get; set; }
I could write another class that has the same properties but with other JsonProperties depending on the Version they are on, but that seems like something to try last, unless there is no possible way to do this easier.
Update
I agree that this question is a duplicate of the question above. However since the given keys in the JSON changes significantly, I will be making duplicate objects (OrderV1 , OrderV2 as example).
Simply replacing some characters into other ones will not be enough in my case.