This may be too much trouble, but I have an object I'm trying to deserialize that looks like this:
{
"Status": { ... a status object ... }
"Data" : {... could be any one of 10 other data classes I have ... }
}
I want to deserialize this object into a response class that looks like this:
public class Response
{
public Status Status;
public Stream Data;
}
Then later deserialize the Data attribute into another class. However, if I make the type of the data attribute a Stream, I get a Security Exception when I try to deserialize. Likewise, if I make it a string, the deserialize just calls the toString() method on the data object (after deserializing it) and puts that as the attribute, which isn't helpful.
Is there any way to accomplish something like this? I'm trying to avoid having 10 different classes that all look a lot like Response but just have a different type for the Data attribute. If there's a way that I can dynamically set the type of the Data attribute that might also solve the situation.
Thanks for any help!