I'm consuming json from another party - I have no control over the format.
One property is poorly formatted in that it's an array of objects when there is more than one object but it's just an object when there's only one. Obviously, I'm getting an error when deserializing.
I'm assuming I'm going to have to write a custom converter to handle this. I'd prefer to have the serializing/deserializing of the underlying object(s) still handled by the default converter. Is that possible?
Here's an example of the json if only one "COMMENT":
{
"COMMENT": {
"@_SourceType": "MySource",
"@_Type": "StatusCode",
"@_Code": "11",
"_Text": "THIS IS SOME TEXT"
}
}
Here's an example if there's more than one:
{
"COMMENT": [
{
"@_SourceType": "MySource",
"@_Type": "StatusCode",
"@_Code": "11",
"_Text": "THIS IS SOME TEXT"
},
{
"@_SourceType": "MySource2",
"@_Type": "StatusCode2",
"@_Code": "12",
"_Text": "THIS IS SOME MORE TEXT"
}
]
}
I would like both to deserialize into a COMMENT array.