System.Text.Json Polymorphic Deserialization not binding Type Discriminator property
04:40 18 Nov 2025

I'm trying to do a polymorphic deserialization using System.Text.Json in net-8.0. Here is my schema.

[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
[JsonDerivedType(typeof(Manager), "Manager")]
[JsonDerivedType(typeof(Developer), "Developer")]
public class Employee
{
    public string Type { get; set; }
    public string Name { get; set; }
}

public class Manager : Employee
{
    public string Phone { get; set; }
}

public class Developer : Employee
{
    public string Laptop { get; set; }
}

Here is my json.

[
  {
    "type": "Manager",
    "name": "Bob",
    "phone": "9876543210"
  },
  {
    "type": "Developer",
    "name": "Charlie",
    "laptop": "MacBook Pro"
  }
]

and I'm doing this

var jsonFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Employees.json");
var employeesContent = File.ReadAllText(jsonFilePath);

var jsonSerializerOptions = new JsonSerializerOptions();
jsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
var employees = JsonSerializer.Deserialize>(employeesContent, jsonSerializerOptions);

And the Type property inside Employee class is always null as shown in below screen shot.

Debug output

Please assist me on what I'm missing.

c# json .net .net-core system.text.json