public static void Main()
var serviceRequest1 = new ServiceRequest() {
TemplateData = new SREscalation() {
AccountNumber = "123456",
Description = "Test account",
ComplaintType = "Account"
var serviceRequest2 = new ServiceRequest() {
TemplateData = new SRInvestment() {
AccountNumber = "123456",
Description = "Test account",
Beneficiary = "John Smith"
var jsonServiceRequest1 = JsonConvert.SerializeObject(serviceRequest1);
Console.WriteLine(jsonServiceRequest1);
var jsonServiceRequest2 = JsonConvert.SerializeObject(serviceRequest2);
Console.WriteLine(jsonServiceRequest2);
var serviceRequest1Converted = JsonConvert.DeserializeObject<ServiceRequest>(jsonServiceRequest1);
Console.WriteLine(serviceRequest1Converted.TemplateData.GetType());
var serviceRequest2Converted = JsonConvert.DeserializeObject<ServiceRequest>(jsonServiceRequest2);
Console.WriteLine(serviceRequest2Converted.TemplateData.GetType());
public string SrNumber {get;set;}
public BaseTemplateData TemplateData {get;set;}
[JsonConverter(typeof(JsonSubtypes))]
[JsonSubtypes.KnownSubTypeWithProperty(typeof(SRInvestment), "Beneficiary")]
[JsonSubtypes.KnownSubTypeWithProperty(typeof(SREscalation), "ComplaintType")]
public string AccountNumber { get; set; }
public string Description { get; set; }
class SRInvestment : BaseTemplateData
public string Beneficiary {get;set; }
class SREscalation : BaseTemplateData
public string ComplaintType { get; set; }