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

JsonDerivedTypeAttribute

When placed on a type declaration, indicates that the specified subtype should be opted into polymorphic serialization.
public Type DerivedType { get; }

A derived type that should be supported in polymorphic serialization of the declared base type.

public object TypeDiscriminator { get; }

The type discriminator identifier to be used for the serialization of the subtype.

public JsonDerivedTypeAttribute(Type derivedType)

Initializes a new attribute with specified parameters.

public JsonDerivedTypeAttribute(Type derivedType, string typeDiscriminator)

Initializes a new attribute with specified parameters.

public JsonDerivedTypeAttribute(Type derivedType, int typeDiscriminator)

Initializes a new attribute with specified parameters.