So I'm using json.net to deserialize some data from the interwebs. And the bumblebrains providing the data are making it hard for me. The data type of one of the properties of the object I'm trying to deserialize varies depending on the contents of another property in the object, like so:
{ "typeindicator": "A", "object_I_Need": { ...formatted for object type A ... } }
Or
{ "typeindicator": "B", "object_I_Need": { ...formatted for object type B ... } }
I need the "object_I_Need" regardless of whether it's type A or B and I have the schema for both types.
I don't need to solve this completely in the deserializer. I just JsonExtensionDataAttribute to check for unknown fields so I was wondering if I could just let the object_I_Need fall into that and then deserialize that seperately... is there a way to do that?
What are my options here? I guess I could deserialize the whole thing into a dynamic object, decide what type the object_I_Need is and serialize it again? I hope there's a better way, though. Suggestions appreciated.
Thanks, Crash