This project has moved. For the latest updates, please go here.

Deserialize Polymorphic Object

Apr 24, 2012 at 7:37 PM


Anybody know if supports the following scenario and if it does please show me how

I have the following model structure

public abstract class Animal   {


public class Cat : Animal{

I want to deserialize to an container object that has a list of animal objects

public class Zoo{ 

public IList<Animal> AnimalList;


In the Json the content list contains a drived type: Cat

"animalList":[    {        "type":"Cat",

So I need to be able to configure to be able to create a list of (Cat)animal objects. Obviously the derived class of Animal can change, so whatever comes in Json, will know to create a derived Type.