Here is a fun problem: how do you deserialize an array of objects with different types, but all of which inherit from the same super class?
If you are using Newtonsoft's Json.NET, then this is actually rather easy to implement!
Example
Here are three classes...
public abstract class Pet { public string Name { get; set; } }
public class Dog : Pet { public string FavoriteToy { get; set; } }
public class Cat : Pet { public bool WantsToKillYou { get; set; } }
...here is an array with instances of those objects mixed together...
new Pet[]
{
new Cat { Name = "Sql", WantsToKillYou = true },
new Cat { Name = "Linq", WantsToKillYou = false },
new Dog { Name = "Taboo", FavoriteToy = "Sql" }
}
...and now let's make it serialize and deseriailze! :)
Extending the JsonConverter
This tactic is actually quite simple! You need to extend a JsonConverter for your specific super class that is able to somehow uniquely identify each child class. In this example we look for a specific property that only exists on the child class, and Newtonsoft's JObjects and JTokens make this very easy to do!