Imagine a simple IEnumerable<BaseType> Get() controller action. It returns an enumeration of different types, all of which are based on BaseType.
When a client requests XML, the result looks something like this:
<ArrayOfBaseType> <BaseType i:type="DerivedType1"><A>value</A></BaseType> <BaseType i:type="DerivedType2"><B>value</B></BaseType> <BaseType i:type="DerivedType3"><C>value</C></BaseType> </ArrayOfBaseType>
As you can see, the type of the derived class is passed in the i:type attribute.
If the client requests JSON, this information is missing:
[ {"A":"value"}, {"B":"value"}, {"C":"value"} ]
How to fix it?
Daniel Hilgarth
source share