I'm trying to deserialize a JSON payload that for reasons outside of my control contain a property (i.e. member) named exactly the same as its class name. Something like:
{
...,
"Id": {
"A" : "Hello",
"B" : "World",
...
"Id" : 1
},
...
}
When I derive a class from this payload, I need something like this:
class Id{
public string A, B;
public int Id;
}
Obviously, the compiler complains with: member names cannot be the same as enclosing type
How can I rename the member (or the class for that effect), so Json.NET (the library I'm using to maker it easier) is able to "hydrate" payloads just by calling JsonConvert.DeserializeObject<T>
?