I have a client which can call two different versions of a service.
One service only sends a single value:
{
"value" : { ... }
}
The second service always returns multiple values:
{
"values" : [
{ ... },
{ ... }
]
}
Ideally, I'd like to represent this with a single object in my client classes so the user never sees whether it's a single value or multiple values.
public class MyValues
{
public List<Stuff> Values { get; set; }
public Thing Other { get; set; }
}
I think that the only way I'll be able to accomplish this is with a custom JsonConverter
class which I apply to MyValues
, but I really only want to do something custom when I'm deserializing the property value
. I can't seem to figure out if an IContractResolver would be a better way to go (e.g. somehow attach a phantom property to MyValues that deserializes value
and puts it into Values
.
If I create a custom converter, how to I tell it to deserialize everything else normally (e.g. if Other
has an extra properties make sure they are handled appropriately, etc.)