I’m trying to use the DataContractJsonSerializer to serialize and deserialize a c# object that contains an object[] of differing types.
I need to find all the types used by the XmlRequest and the objects in it’s object[] so I an pass the list of Types to the DataContractJsonSerializer.
The object[] in XmlRequest will contain different types. TypeX, TypeY, string, int, TypeZ
var sr = new DataContractJsonSerializer(typeof(XmlRequest), knownTypes);
Xml Request Class:
[DataContract]
public class XmlRequest
{
[DataMember]
public object[] Parameters { get; set; }
[DataMember]
public string Name { get; set; }
}
I figured out how to do this through configuration instead of trying to discover these items at runtime.