Editare

Partajați prin


JsonSerializerOptions.TryGetTypeInfo(Type, JsonTypeInfo) Method

Definition

Tries to get the JsonTypeInfo contract metadata resolved by the current JsonSerializerOptions instance.

public:
 bool TryGetTypeInfo(Type ^ type, [Runtime::InteropServices::Out] System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ % typeInfo);
public bool TryGetTypeInfo (Type type, out System.Text.Json.Serialization.Metadata.JsonTypeInfo? typeInfo);
member this.TryGetTypeInfo : Type * JsonTypeInfo -> bool
Public Function TryGetTypeInfo (type As Type, ByRef typeInfo As JsonTypeInfo) As Boolean

Parameters

type
Type

The type to resolve contract metadata for.

typeInfo
JsonTypeInfo

When this method returns, contains the resolved contract metadata, or null if the contract could not be resolved.

Returns

true if a contract for type was found, or false otherwise.

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 will return a cached instance for the metadata.

Applies to