Edit

Share via


JsonSerializerOptions.GetConverter(Type) Method

Definition

Returns the converter for the specified type.

public:
 System::Text::Json::Serialization::JsonConverter ^ GetConverter(Type ^ typeToConvert);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Getting a converter for a type may require reflection which depends on runtime code generation.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Getting a converter for a type may require reflection which depends on unreferenced code.")]
public System.Text.Json.Serialization.JsonConverter GetConverter(Type typeToConvert);
public System.Text.Json.Serialization.JsonConverter GetConverter(Type typeToConvert);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Getting a converter for a type may require reflection which depends on unreferenced code.")]
public System.Text.Json.Serialization.JsonConverter GetConverter(Type typeToConvert);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Getting a converter for a type may require reflection which depends on runtime code generation.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Getting a converter for a type may require reflection which depends on unreferenced code.")>]
member this.GetConverter : Type -> System.Text.Json.Serialization.JsonConverter
member this.GetConverter : Type -> System.Text.Json.Serialization.JsonConverter
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Getting a converter for a type may require reflection which depends on unreferenced code.")>]
member this.GetConverter : Type -> System.Text.Json.Serialization.JsonConverter
Public Function GetConverter (typeToConvert As Type) As JsonConverter

Parameters

typeToConvert
Type

The type to return a converter for.

Returns

The first converter that supports the given type.

Attributes

Exceptions

The configured JsonConverter for typeToConvert returned an invalid converter.

There is no compatible JsonConverter for typeToConvert or its serializable members.

Remarks

For more information, see How to write custom converters for JSON serialization (marshalling) in .NET.

Applies to