Context: I'm serializing data into a message queue. The message queue will accept heterogeneous types, that need to be deserialized by the receiver.
Problem: Normally when deserializing, I'd use code like:
JsonConvert.DeserializeObject<Type>(object);
However, because the types are heterogeneous, I won't trivially know the desired type ahead of time.
I know I can use TypeNameHandling to embed the type in the JSON, but when calling DeserializeObject, I still don't get a strongly typed result (as in, the returned object isn't cast to the embedded Type already).
Question: Can Json.Net cast a deserialized object to the type embedded in the Json? If not, is my best option to get the type from the JSON and then call DeserializeObject so the object can be cast?