JsonSerializerOptions.GetTypeInfo(Type) Method

Definition

Gets the JsonTypeInfo contract metadata resolved by the current JsonSerializerOptions instance.

C#
public System.Text.Json.Serialization.Metadata.JsonTypeInfo GetTypeInfo(Type type);

Parameters

type
Type

The type to resolve contract metadata for.

Returns

The contract metadata resolved for type.

Exceptions

type is null.

type is not valid for serialization.

Remarks

Returned metadata can be downcast to JsonTypeInfo<T> and used with the relevant JsonSerializer overloads.

If the JsonSerializerOptions instance is locked for modification, the method returns a cached instance for the metadata.

Applies to

Product Versions
.NET 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)