public abstract class Animal
string LegsCount { get; set; }
public class Dog : Animal
public virtual DogColors Color { get; }
public string Breed { get; set; }
public class Cat : Animal
public bool Declawed { get; set; }
public class BlackDog : Dog
public override DogColors Color { get; } = DogColors.Black;
public class WhiteDog : Dog
public override DogColors Color { get; } = DogColors.White;
public static void Main()
var settings = new JsonSerializerSettings();
settings.Converters.Add(JsonSubtypesWithPropertyConverterBuilder
.RegisterSubtypeWithProperty<Dog>("Breed")
.RegisterSubtypeWithProperty<Cat>("Declawed")
settings.Converters.Add(JsonSubtypesConverterBuilder
.RegisterSubtype<BlackDog>(DogColors.Black)
.RegisterSubtype<WhiteDog>(DogColors.White)
result = JsonConvert.DeserializeObject<Animal>("{\n \"LegsCount\": \"4\",\n \"Declawed\": true\n}", settings);
Console.WriteLine(result.GetType());
result = JsonConvert.DeserializeObject<Animal>("{\n \"LegsCount\": \"4\",\n \"Breed\": \"Doberman\",\n \"Color\": \"Black\"\n}", settings);
Console.WriteLine(result.GetType());
result = JsonConvert.DeserializeObject<Animal>("{\n \"LegsCount\": \"4\",\n \"Breed\": \"Husky\",\n \"Color\": \"White\"\n}", settings);
Console.WriteLine(result.GetType());
result = JsonConvert.DeserializeObject<Animal>("{\n \"LegsCount\": \"4\",\n \"Breed\": \"Chihuahua\"\n}", settings);
Console.WriteLine(result.GetType());
Console.WriteLine(e.Message);