<PackageReference Include="System.Text.Json" Version="8.0.5" />

JsonPolymorphicAttribute

public sealed class JsonPolymorphicAttribute : JsonAttribute
When placed on a type, indicates that the type should be serialized polymorphically.
public bool IgnoreUnrecognizedTypeDiscriminators { get; set; }

Gets or sets a value that indicates whether the deserializer should ignore any unrecognized type discriminator IDs and revert to the contract of the base type.

public string TypeDiscriminatorPropertyName { get; set; }

Gets or sets a custom type discriminator property name for the polymorhic type. Uses the default '$type' property name if left unset.

Gets or sets the behavior when serializing an undeclared derived runtime type.

Creates a new JsonPolymorphicAttribute instance.