JsonSerializer.Deserialize Method

Definition

Overloads

Deserialize(Stream, JsonTypeInfo)

Reads the UTF-8 encoded text representing a single JSON value into an instance specified by the jsonTypeInfo. The Stream will be read to completion.

Deserialize(Utf8JsonReader, Type, JsonSerializerContext)

Reads one JSON value (including objects or arrays) from the provided reader into a returnType.

Deserialize(Utf8JsonReader, Type, JsonSerializerOptions)

Reads one JSON value (including objects or arrays) from the provided reader and converts it into an instance of a specified type.

Deserialize(JsonNode, Type, JsonSerializerOptions)

Converts the JsonNode representing a single JSON value into a returnType.

Deserialize(JsonElement, Type, JsonSerializerContext)

Converts the JsonElement representing a single JSON value into a returnType.

Deserialize(JsonElement, Type, JsonSerializerOptions)

Converts the JsonElement representing a single JSON value into a returnType.

Deserialize(JsonDocument, Type, JsonSerializerContext)

Converts the JsonDocument representing a single JSON value into a returnType.

Deserialize(JsonDocument, Type, JsonSerializerOptions)

Converts the JsonDocument representing a single JSON value into a returnType.

Deserialize(String, Type, JsonSerializerContext)

Parses the text representing a single JSON value into a returnType.

Deserialize(String, Type, JsonSerializerOptions)

Parses the text representing a single JSON value into an instance of a specified type.

Deserialize(ReadOnlySpan<Char>, Type, JsonSerializerContext)

Parses the text representing a single JSON value into a returnType.

Deserialize(ReadOnlySpan<Char>, Type, JsonSerializerOptions)

Parses the text representing a single JSON value into an instance of a specified type.

Deserialize(JsonNode, Type, JsonSerializerContext)

Converts the JsonNode representing a single JSON value into a returnType.

Deserialize(ReadOnlySpan<Byte>, Type, JsonSerializerOptions)

Parses the UTF-8 encoded text representing a single JSON value into an instance of a specified type.

Deserialize(ReadOnlySpan<Byte>, Type, JsonSerializerContext)

Parses the UTF-8 encoded text representing a single JSON value into a returnType.

Deserialize(ReadOnlySpan<Byte>, JsonTypeInfo)

Parses the UTF-8 encoded text representing a single JSON value into an instance specified by the jsonTypeInfo.

Deserialize(String, JsonTypeInfo)

Parses the text representing a single JSON value into an instance specified by the jsonTypeInfo.

Deserialize(JsonDocument, JsonTypeInfo)

Converts the JsonDocument representing a single JSON value into an instance specified by the jsonTypeInfo.

Deserialize(ReadOnlySpan<Char>, JsonTypeInfo)

Parses the text representing a single JSON value into an instance specified by the jsonTypeInfo.

Deserialize(JsonNode, JsonTypeInfo)

Converts the JsonNode representing a single JSON value into an instance specified by the jsonTypeInfo.

Deserialize(Utf8JsonReader, JsonTypeInfo)

Reads one JSON value (including objects or arrays) from the provided reader into an instance specified by the jsonTypeInfo.

Deserialize(Stream, Type, JsonSerializerOptions)

Reads the UTF-8 encoded text representing a single JSON value into a returnType. The Stream will be read to completion.

Deserialize(Stream, Type, JsonSerializerContext)

Reads the UTF-8 encoded text representing a single JSON value into a returnType. The Stream will be read to completion.

Deserialize(JsonElement, JsonTypeInfo)

Converts the JsonElement representing a single JSON value into an instance specified by the jsonTypeInfo.

Deserialize<TValue>(Utf8JsonReader, JsonTypeInfo<TValue>)

Reads one JSON value (including objects or arrays) from the provided reader into a TValue.

Deserialize<TValue>(JsonDocument, JsonTypeInfo<TValue>)

Converts the JsonDocument representing a single JSON value into a TValue.

Deserialize<TValue>(Utf8JsonReader, JsonSerializerOptions)

Reads one JSON value (including objects or arrays) from the provided reader into an instance of the type specified by a generic type parameter.

Deserialize<TValue>(JsonNode, JsonTypeInfo<TValue>)

Converts the JsonNode representing a single JSON value into a TValue.

Deserialize<TValue>(JsonNode, JsonSerializerOptions)

Converts the JsonNode representing a single JSON value into a TValue.

Deserialize<TValue>(JsonElement, JsonTypeInfo<TValue>)

Converts the JsonElement representing a single JSON value into a TValue.

Deserialize<TValue>(JsonElement, JsonSerializerOptions)

Converts the JsonElement representing a single JSON value into a TValue.

Deserialize<TValue>(JsonDocument, JsonSerializerOptions)

Converts the JsonDocument representing a single JSON value into a TValue.

Deserialize<TValue>(ReadOnlySpan<Char>, JsonSerializerOptions)

Parses the text representing a single JSON value into an instance of the type specified by a generic type parameter.

Deserialize<TValue>(String, JsonSerializerOptions)

Parses the text representing a single JSON value into an instance of the type specified by a generic type parameter.

Deserialize<TValue>(ReadOnlySpan<Char>, JsonTypeInfo<TValue>)

Parses the text representing a single JSON value into a TValue.

Deserialize<TValue>(ReadOnlySpan<Byte>, JsonTypeInfo<TValue>)

Parses the UTF-8 encoded text representing a single JSON value into a TValue.

Deserialize<TValue>(ReadOnlySpan<Byte>, JsonSerializerOptions)

Parses the UTF-8 encoded text representing a single JSON value into an instance of the type specified by a generic type parameter.

Deserialize<TValue>(Stream, JsonTypeInfo<TValue>)

Reads the UTF-8 encoded text representing a single JSON value into a TValue. The Stream will be read to completion.

Deserialize<TValue>(Stream, JsonSerializerOptions)

Reads the UTF-8 encoded text representing a single JSON value into a TValue. The Stream will be read to completion.

Deserialize<TValue>(String, JsonTypeInfo<TValue>)

Parses the text representing a single JSON value into a TValue.

Deserialize(Stream, JsonTypeInfo)

Reads the UTF-8 encoded text representing a single JSON value into an instance specified by the jsonTypeInfo. The Stream will be read to completion.

public:
 static System::Object ^ Deserialize(System::IO::Stream ^ utf8Json, System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ jsonTypeInfo);
public static object? Deserialize (System.IO.Stream utf8Json, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo);
static member Deserialize : System.IO.Stream * System.Text.Json.Serialization.Metadata.JsonTypeInfo -> obj
Public Function Deserialize (utf8Json As Stream, jsonTypeInfo As JsonTypeInfo) As Object

Parameters

utf8Json
Stream

JSON data to parse.

jsonTypeInfo
JsonTypeInfo

Metadata about the type to convert.

Returns

A jsonTypeInfo representation of the JSON value.

Exceptions

utf8Json or jsonTypeInfo is null.

The JSON is invalid, or there is remaining data in the Stream.

Applies to

Deserialize(Utf8JsonReader, Type, JsonSerializerContext)

Reads one JSON value (including objects or arrays) from the provided reader into a returnType.

public:
 static System::Object ^ Deserialize(System::Text::Json::Utf8JsonReader % reader, Type ^ returnType, System::Text::Json::Serialization::JsonSerializerContext ^ context);
public static object? Deserialize (ref System.Text.Json.Utf8JsonReader reader, Type returnType, System.Text.Json.Serialization.JsonSerializerContext context);
static member Deserialize : Utf8JsonReader * Type * System.Text.Json.Serialization.JsonSerializerContext -> obj
Public Function Deserialize (ByRef reader As Utf8JsonReader, returnType As Type, context As JsonSerializerContext) As Object

Parameters

reader
Utf8JsonReader

The reader to read.

returnType
Type

The type of the object to convert to and return.

context
JsonSerializerContext

A metadata provider for serializable types.

Returns

A returnType representation of the JSON value.

Exceptions

returnType or context is null.

The JSON is invalid, returnType is not compatible with the JSON, or a value could not be read from the reader.

reader is using unsupported options.

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

The GetTypeInfo(Type) method on the provided context did not return a compatible JsonTypeInfo for returnType.

Remarks

If the TokenType property of reader is PropertyName or None, the reader will be advanced by one call to Read() to determine the start of the value.

Upon completion of this method, reader is positioned at the final token in the JSON value. If an exception is thrown, the reader is reset to the state it was in when the method was called.

This method makes a copy of the data the reader acted on, so there is no caller requirement to maintain data integrity beyond the return of this method.

The JsonReaderOptions used to create the instance of the Utf8JsonReader take precedence over the JsonSerializerOptions when they conflict. Hence, AllowTrailingCommas, MaxDepth, and CommentHandling are used while reading.

Applies to

Deserialize(Utf8JsonReader, Type, JsonSerializerOptions)

Reads one JSON value (including objects or arrays) from the provided reader and converts it into an instance of a specified type.

public static object? Deserialize (ref System.Text.Json.Utf8JsonReader reader, Type returnType, System.Text.Json.JsonSerializerOptions? options = default);
public static object Deserialize (ref System.Text.Json.Utf8JsonReader reader, Type returnType, System.Text.Json.JsonSerializerOptions options = default);
static member Deserialize : Utf8JsonReader * Type * System.Text.Json.JsonSerializerOptions -> obj
Public Shared Function Deserialize (ByRef reader As Utf8JsonReader, returnType As Type, Optional options As JsonSerializerOptions = Nothing) As Object
Public Function Deserialize (ByRef reader As Utf8JsonReader, returnType As Type, Optional options As JsonSerializerOptions = Nothing) As Object

Parameters

reader
Utf8JsonReader

The reader to read the JSON from.

returnType
Type

The type of the object to convert to and return.

options
JsonSerializerOptions

Options to control the serializer behavior during reading.

Returns

A returnType representation of the JSON value.

Exceptions

returnType is null.

The JSON is invalid.

-or-

returnType is not compatible with the JSON.

-or-

A value could not be read from the reader.

reader is using unsupported options.

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

Remarks

If the TokenType property of reader is JsonTokenType.PropertyName or JsonTokenType.None, the reader will be advanced by one call to Utf8JsonReader.Read() to determine the start of the value.

Upon completion of this method, reader will be positioned at the final token in the JSON value. If an exception is thrown, the reader is reset to the state it was in when the method was called.

This method makes a copy of the data the reader acted on, so there is no caller requirement to maintain data integrity beyond the return of this method.

The JsonReaderOptions used to create the instance of the Utf8JsonReader take precedence over the JsonSerializerOptions when they conflict. Hence, JsonReaderOptions.AllowTrailingCommas, JsonReaderOptions.MaxDepth, and JsonReaderOptions.CommentHandling are used while reading.

For more information, see How to serialize and deserialize JSON.

Applies to

Deserialize(JsonNode, Type, JsonSerializerOptions)

Converts the JsonNode representing a single JSON value into a returnType.

public static object? Deserialize (this System.Text.Json.Nodes.JsonNode? node, Type returnType, System.Text.Json.JsonSerializerOptions? options = default);
static member Deserialize : System.Text.Json.Nodes.JsonNode * Type * System.Text.Json.JsonSerializerOptions -> obj
<Extension()>
Public Function Deserialize (node As JsonNode, returnType As Type, Optional options As JsonSerializerOptions = Nothing) As Object

Parameters

node
JsonNode

The JsonNode to convert.

returnType
Type

The type of the object to convert to and return.

options
JsonSerializerOptions

Options to control the behavior during parsing.

Returns

A returnType representation of the JSON value.

Exceptions

returnType is not compatible with the JSON.

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

Applies to

Deserialize(JsonElement, Type, JsonSerializerContext)

Converts the JsonElement representing a single JSON value into a returnType.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Object ^ Deserialize(System::Text::Json::JsonElement element, Type ^ returnType, System::Text::Json::Serialization::JsonSerializerContext ^ context);
public static object? Deserialize (this System.Text.Json.JsonElement element, Type returnType, System.Text.Json.Serialization.JsonSerializerContext context);
static member Deserialize : System.Text.Json.JsonElement * Type * System.Text.Json.Serialization.JsonSerializerContext -> obj
<Extension()>
Public Function Deserialize (element As JsonElement, returnType As Type, context As JsonSerializerContext) As Object

Parameters

element
JsonElement

The JsonElement to convert.

returnType
Type

The type of the object to convert to and return.

context
JsonSerializerContext

A metadata provider for serializable types.

Returns

A returnType representation of the JSON value.

Exceptions

returnType is null.

-or-

context is null.

The JSON is invalid.

-or-

returnType is not compatible with the JSON.

-or-

There is remaining data in the string beyond a single JSON value.

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

The GetTypeInfo(Type) method of the provided context returns null for the type to convert.

Applies to

Deserialize(JsonElement, Type, JsonSerializerOptions)

Converts the JsonElement representing a single JSON value into a returnType.

public static object? Deserialize (this System.Text.Json.JsonElement element, Type returnType, System.Text.Json.JsonSerializerOptions? options = default);
static member Deserialize : System.Text.Json.JsonElement * Type * System.Text.Json.JsonSerializerOptions -> obj
<Extension()>
Public Function Deserialize (element As JsonElement, returnType As Type, Optional options As JsonSerializerOptions = Nothing) As Object

Parameters

element
JsonElement

The JsonElement to convert.

returnType
Type

The type of the object to convert to and return.

options
JsonSerializerOptions

Options to control the behavior during parsing.

Returns

A returnType representation of the JSON value.

Exceptions

returnType is null.

returnType is not compatible with the JSON.

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

Applies to

Deserialize(JsonDocument, Type, JsonSerializerContext)

Converts the JsonDocument representing a single JSON value into a returnType.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Object ^ Deserialize(System::Text::Json::JsonDocument ^ document, Type ^ returnType, System::Text::Json::Serialization::JsonSerializerContext ^ context);
public static object? Deserialize (this System.Text.Json.JsonDocument document, Type returnType, System.Text.Json.Serialization.JsonSerializerContext context);
static member Deserialize : System.Text.Json.JsonDocument * Type * System.Text.Json.Serialization.JsonSerializerContext -> obj
<Extension()>
Public Function Deserialize (document As JsonDocument, returnType As Type, context As JsonSerializerContext) As Object

Parameters

document
JsonDocument

The JsonDocument to convert.

returnType
Type

The type of the object to convert to and return.

context
JsonSerializerContext

A metadata provider for serializable types.

Returns

A returnType representation of the JSON value.

Exceptions

document is null.

-or-

returnType is null.

-or-

context is null.

The JSON is invalid.

-or-

returnType is not compatible with the JSON.

-or-

There is remaining data in the string beyond a single JSON value.

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

The GetTypeInfo(Type) method of the provided context returns null for the type to convert.

Applies to

Deserialize(JsonDocument, Type, JsonSerializerOptions)

Converts the JsonDocument representing a single JSON value into a returnType.

public static object? Deserialize (this System.Text.Json.JsonDocument document, Type returnType, System.Text.Json.JsonSerializerOptions? options = default);
static member Deserialize : System.Text.Json.JsonDocument * Type * System.Text.Json.JsonSerializerOptions -> obj
<Extension()>
Public Function Deserialize (document As JsonDocument, returnType As Type, Optional options As JsonSerializerOptions = Nothing) As Object

Parameters

document
JsonDocument

The JsonDocument to convert.

returnType
Type

The type of the object to convert to and return.

options
JsonSerializerOptions

Options to control the behavior during parsing.

Returns

A returnType representation of the JSON value.

Exceptions

document or returnType is null.

returnType is not compatible with the JSON.

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

Applies to

Deserialize(String, Type, JsonSerializerContext)

Parses the text representing a single JSON value into a returnType.

public:
 static System::Object ^ Deserialize(System::String ^ json, Type ^ returnType, System::Text::Json::Serialization::JsonSerializerContext ^ context);
public static object? Deserialize (string json, Type returnType, System.Text.Json.Serialization.JsonSerializerContext context);
static member Deserialize : string * Type * System.Text.Json.Serialization.JsonSerializerContext -> obj
Public Function Deserialize (json As String, returnType As Type, context As JsonSerializerContext) As Object

Parameters

json
String

JSON text to parse.

returnType
Type

The type of the object to convert to and return.

context
JsonSerializerContext

A metadata provider for serializable types.

Returns

A returnType representation of the JSON value.

Exceptions

json or returnType is null.

-or-

context is null.

The JSON is invalid.

-or-

returnType is not compatible with the JSON.

-or-

There is remaining data in the string beyond a single JSON value.

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

The GetTypeInfo(Type) method of the provided context returns null for the type to convert.

Remarks

Using a String is not as efficient as using the UTF-8 methods since the implementation natively uses UTF-8.

Applies to

Deserialize(String, Type, JsonSerializerOptions)

Parses the text representing a single JSON value into an instance of a specified type.

public static object? Deserialize (string json, Type returnType, System.Text.Json.JsonSerializerOptions? options = default);
public static object Deserialize (string json, Type returnType, System.Text.Json.JsonSerializerOptions options = default);
static member Deserialize : string * Type * System.Text.Json.JsonSerializerOptions -> obj
Public Shared Function Deserialize (json As String, returnType As Type, Optional options As JsonSerializerOptions = Nothing) As Object
Public Function Deserialize (json As String, returnType As Type, Optional options As JsonSerializerOptions = Nothing) As Object

Parameters

json
String

The JSON text to parse.

returnType
Type

The type of the object to convert to and return.

options
JsonSerializerOptions

Options to control the behavior during parsing.

Returns

A returnType representation of the JSON value.

Exceptions

json or returnType is null.

The JSON is invalid.

-or-

TValue is not compatible with the JSON.

-or-

There is remaining data in the string beyond a single JSON value.

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

Remarks

Using a String is not as efficient as using the UTF-8 methods since the implementation natively uses UTF-8.

For more information, see How to serialize and deserialize JSON.

Applies to

Deserialize(ReadOnlySpan<Char>, Type, JsonSerializerContext)

Parses the text representing a single JSON value into a returnType.

public:
 static System::Object ^ Deserialize(ReadOnlySpan<char> json, Type ^ returnType, System::Text::Json::Serialization::JsonSerializerContext ^ context);
public static object? Deserialize (ReadOnlySpan<char> json, Type returnType, System.Text.Json.Serialization.JsonSerializerContext context);
static member Deserialize : ReadOnlySpan<char> * Type * System.Text.Json.Serialization.JsonSerializerContext -> obj
Public Function Deserialize (json As ReadOnlySpan(Of Char), returnType As Type, context As JsonSerializerContext) As Object

Parameters

json
ReadOnlySpan<Char>

JSON text to parse.

returnType
Type

The type of the object to convert to and return.

context
JsonSerializerContext

A metadata provider for serializable types.

Returns

A returnType representation of the JSON value.

Exceptions

json or returnType is null.

-or-

context is null.

The JSON is invalid.

-or-

returnType is not compatible with the JSON.

-or-

There is remaining data in the string beyond a single JSON value.

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

The GetTypeInfo(Type) method of the provided context returns null for the type to convert.

Remarks

Using a String is not as efficient as using the UTF-8 methods since the implementation natively uses UTF-8.

Applies to

Deserialize(ReadOnlySpan<Char>, Type, JsonSerializerOptions)

Parses the text representing a single JSON value into an instance of a specified type.

public static object? Deserialize (ReadOnlySpan<char> json, Type returnType, System.Text.Json.JsonSerializerOptions? options = default);
static member Deserialize : ReadOnlySpan<char> * Type * System.Text.Json.JsonSerializerOptions -> obj
Public Function Deserialize (json As ReadOnlySpan(Of Char), returnType As Type, Optional options As JsonSerializerOptions = Nothing) As Object

Parameters

json
ReadOnlySpan<Char>

The JSON text to parse.

returnType
Type

The type of the object to convert to and return.

options
JsonSerializerOptions

Options to control the behavior during parsing.

Returns

A returnType representation of the JSON value.

Exceptions

returnType is null.

The JSON is invalid.

-or-

returnType is not compatible with the JSON.

-or-

There is remaining data in the span beyond a single JSON value.

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

Remarks

Using a UTF-16 span is not as efficient as using the UTF-8 methods since the implementation natively uses UTF-8.

Applies to

Deserialize(JsonNode, Type, JsonSerializerContext)

Converts the JsonNode representing a single JSON value into a returnType.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Object ^ Deserialize(System::Text::Json::Nodes::JsonNode ^ node, Type ^ returnType, System::Text::Json::Serialization::JsonSerializerContext ^ context);
public static object? Deserialize (this System.Text.Json.Nodes.JsonNode? node, Type returnType, System.Text.Json.Serialization.JsonSerializerContext context);
static member Deserialize : System.Text.Json.Nodes.JsonNode * Type * System.Text.Json.Serialization.JsonSerializerContext -> obj
<Extension()>
Public Function Deserialize (node As JsonNode, returnType As Type, context As JsonSerializerContext) As Object

Parameters

node
JsonNode

The JsonNode to convert.

returnType
Type

The type of the object to convert to and return.

context
JsonSerializerContext

A metadata provider for serializable types.

Returns

A returnType representation of the JSON value.

Exceptions

returnType is null.

-or-

context is null.

The JSON is invalid.

-or-

returnType is not compatible with the JSON.

-or-

There is remaining data in the string beyond a single JSON value.

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

The GetTypeInfo(Type) method of the provided context returns null for the type to convert.

Applies to

Deserialize(ReadOnlySpan<Byte>, Type, JsonSerializerOptions)

Parses the UTF-8 encoded text representing a single JSON value into an instance of a specified type.

public static object? Deserialize (ReadOnlySpan<byte> utf8Json, Type returnType, System.Text.Json.JsonSerializerOptions? options = default);
public static object Deserialize (ReadOnlySpan<byte> utf8Json, Type returnType, System.Text.Json.JsonSerializerOptions options = default);
static member Deserialize : ReadOnlySpan<byte> * Type * System.Text.Json.JsonSerializerOptions -> obj
Public Shared Function Deserialize (utf8Json As ReadOnlySpan(Of Byte), returnType As Type, Optional options As JsonSerializerOptions = Nothing) As Object
Public Function Deserialize (utf8Json As ReadOnlySpan(Of Byte), returnType As Type, Optional options As JsonSerializerOptions = Nothing) As Object

Parameters

utf8Json
ReadOnlySpan<Byte>

The JSON text to parse.

returnType
Type

The type of the object to convert to and return.

options
JsonSerializerOptions

Options to control the behavior during parsing.

Returns

A returnType representation of the JSON value.

Exceptions

returnType is null.

The JSON is invalid.

-or-

returnType is not compatible with the JSON.

-or-

There is remaining data in the span beyond a single JSON value.

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

Remarks

For more information, see How to serialize and deserialize JSON.

Applies to

Deserialize(ReadOnlySpan<Byte>, Type, JsonSerializerContext)

Parses the UTF-8 encoded text representing a single JSON value into a returnType.

public:
 static System::Object ^ Deserialize(ReadOnlySpan<System::Byte> utf8Json, Type ^ returnType, System::Text::Json::Serialization::JsonSerializerContext ^ context);
public static object? Deserialize (ReadOnlySpan<byte> utf8Json, Type returnType, System.Text.Json.Serialization.JsonSerializerContext context);
static member Deserialize : ReadOnlySpan<byte> * Type * System.Text.Json.Serialization.JsonSerializerContext -> obj
Public Function Deserialize (utf8Json As ReadOnlySpan(Of Byte), returnType As Type, context As JsonSerializerContext) As Object

Parameters

utf8Json
ReadOnlySpan<Byte>

JSON text to parse.

returnType
Type

The type of the object to convert to and return.

context
JsonSerializerContext

A metadata provider for serializable types.

Returns

A returnType representation of the JSON value.

Exceptions

returnType is null.

The JSON is invalid, returnType is not compatible with the JSON, or there is remaining data in the Stream.

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

The GetTypeInfo(Type) method on the provided context did not return a compatible JsonTypeInfo for returnType.

Applies to

Deserialize(ReadOnlySpan<Byte>, JsonTypeInfo)

Parses the UTF-8 encoded text representing a single JSON value into an instance specified by the jsonTypeInfo.

public:
 static System::Object ^ Deserialize(ReadOnlySpan<System::Byte> utf8Json, System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ jsonTypeInfo);
public static object? Deserialize (ReadOnlySpan<byte> utf8Json, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo);
static member Deserialize : ReadOnlySpan<byte> * System.Text.Json.Serialization.Metadata.JsonTypeInfo -> obj
Public Function Deserialize (utf8Json As ReadOnlySpan(Of Byte), jsonTypeInfo As JsonTypeInfo) As Object

Parameters

utf8Json
ReadOnlySpan<Byte>

JSON text to parse.

jsonTypeInfo
JsonTypeInfo

Metadata about the type to convert.

Returns

A jsonTypeInfo representation of the JSON value.

Exceptions

The JSON is invalid, or there is remaining data in the buffer.

Applies to

Deserialize(String, JsonTypeInfo)

Parses the text representing a single JSON value into an instance specified by the jsonTypeInfo.

public:
 static System::Object ^ Deserialize(System::String ^ json, System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ jsonTypeInfo);
public static object? Deserialize (string json, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo);
static member Deserialize : string * System.Text.Json.Serialization.Metadata.JsonTypeInfo -> obj
Public Function Deserialize (json As String, jsonTypeInfo As JsonTypeInfo) As Object

Parameters

json
String

JSON text to parse.

jsonTypeInfo
JsonTypeInfo

Metadata about the type to convert.

Returns

A jsonTypeInfo representation of the JSON value.

Exceptions

json is null.

-or-

jsonTypeInfo is null.

The JSON is invalid.

-or-

There is remaining data in the string beyond a single JSON value.

Remarks

Using a String is not as efficient as using the UTF-8 methods since the implementation natively uses UTF-8.

Applies to

Deserialize(JsonDocument, JsonTypeInfo)

Converts the JsonDocument representing a single JSON value into an instance specified by the jsonTypeInfo.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Object ^ Deserialize(System::Text::Json::JsonDocument ^ document, System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ jsonTypeInfo);
public static object? Deserialize (this System.Text.Json.JsonDocument document, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo);
static member Deserialize : System.Text.Json.JsonDocument * System.Text.Json.Serialization.Metadata.JsonTypeInfo -> obj
<Extension()>
Public Function Deserialize (document As JsonDocument, jsonTypeInfo As JsonTypeInfo) As Object

Parameters

document
JsonDocument

The JsonDocument to convert.

jsonTypeInfo
JsonTypeInfo

Metadata about the type to convert.

Returns

A jsonTypeInfo representation of the JSON value.

Exceptions

document is null.

-or-

jsonTypeInfo is null.

Applies to

Deserialize(ReadOnlySpan<Char>, JsonTypeInfo)

Parses the text representing a single JSON value into an instance specified by the jsonTypeInfo.

public:
 static System::Object ^ Deserialize(ReadOnlySpan<char> json, System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ jsonTypeInfo);
public static object? Deserialize (ReadOnlySpan<char> json, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo);
static member Deserialize : ReadOnlySpan<char> * System.Text.Json.Serialization.Metadata.JsonTypeInfo -> obj
Public Function Deserialize (json As ReadOnlySpan(Of Char), jsonTypeInfo As JsonTypeInfo) As Object

Parameters

json
ReadOnlySpan<Char>

JSON text to parse.

jsonTypeInfo
JsonTypeInfo

Metadata about the type to convert.

Returns

A jsonTypeInfo representation of the JSON value.

Exceptions

jsonTypeInfo is null.

The JSON is invalid.

-or-

There is remaining data in the string beyond a single JSON value.

Remarks

Using a String is not as efficient as using the UTF-8 methods since the implementation natively uses UTF-8.

Applies to

Deserialize(JsonNode, JsonTypeInfo)

Converts the JsonNode representing a single JSON value into an instance specified by the jsonTypeInfo.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Object ^ Deserialize(System::Text::Json::Nodes::JsonNode ^ node, System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ jsonTypeInfo);
public static object? Deserialize (this System.Text.Json.Nodes.JsonNode? node, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo);
static member Deserialize : System.Text.Json.Nodes.JsonNode * System.Text.Json.Serialization.Metadata.JsonTypeInfo -> obj
<Extension()>
Public Function Deserialize (node As JsonNode, jsonTypeInfo As JsonTypeInfo) As Object

Parameters

node
JsonNode

The JsonNode to convert.

jsonTypeInfo
JsonTypeInfo

Metadata about the type to convert.

Returns

A jsonTypeInfo representation of the JSON value.

Exceptions

jsonTypeInfo is null.

Applies to

Deserialize(Utf8JsonReader, JsonTypeInfo)

Reads one JSON value (including objects or arrays) from the provided reader into an instance specified by the jsonTypeInfo.

public:
 static System::Object ^ Deserialize(System::Text::Json::Utf8JsonReader % reader, System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ jsonTypeInfo);
public static object? Deserialize (ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo);
static member Deserialize : Utf8JsonReader * System.Text.Json.Serialization.Metadata.JsonTypeInfo -> obj
Public Function Deserialize (ByRef reader As Utf8JsonReader, jsonTypeInfo As JsonTypeInfo) As Object

Parameters

reader
Utf8JsonReader

The reader to read.

jsonTypeInfo
JsonTypeInfo

Metadata about the type to convert.

Returns

A jsonTypeInfo representation of the JSON value.

Exceptions

The JSON is invalid, jsonTypeInfo is not compatible with the JSON, or a value could not be read from the reader.

reader is using unsupported options.

Remarks

If the TokenType property of reader is PropertyName or None, the reader will be advanced by one call to Read() to determine the start of the value.

Upon completion of this method, reader will be positioned at the final token in the JSON value. If an exception is thrown, the reader is reset to the state it was in when the method was called.

This method makes a copy of the data the reader acted on, so there is no caller requirement to maintain data integrity beyond the return of this method.

The JsonReaderOptions used to create the instance of the Utf8JsonReader take precedence over the JsonSerializerOptions when they conflict. Hence, AllowTrailingCommas, MaxDepth, and CommentHandling are used while reading.

Applies to

Deserialize(Stream, Type, JsonSerializerOptions)

Reads the UTF-8 encoded text representing a single JSON value into a returnType. The Stream will be read to completion.

public static object? Deserialize (System.IO.Stream utf8Json, Type returnType, System.Text.Json.JsonSerializerOptions? options = default);
static member Deserialize : System.IO.Stream * Type * System.Text.Json.JsonSerializerOptions -> obj
Public Function Deserialize (utf8Json As Stream, returnType As Type, Optional options As JsonSerializerOptions = Nothing) As Object

Parameters

utf8Json
Stream

JSON data to parse.

returnType
Type

The type of the object to convert to and return.

options
JsonSerializerOptions

Options to control the behavior during reading.

Returns

A returnType representation of the JSON value.

Exceptions

utf8Json or returnType is null.

The JSON is invalid, the returnType is not compatible with the JSON, or there is remaining data in the Stream.

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

Applies to

Deserialize(Stream, Type, JsonSerializerContext)

Reads the UTF-8 encoded text representing a single JSON value into a returnType. The Stream will be read to completion.

public:
 static System::Object ^ Deserialize(System::IO::Stream ^ utf8Json, Type ^ returnType, System::Text::Json::Serialization::JsonSerializerContext ^ context);
public static object? Deserialize (System.IO.Stream utf8Json, Type returnType, System.Text.Json.Serialization.JsonSerializerContext context);
static member Deserialize : System.IO.Stream * Type * System.Text.Json.Serialization.JsonSerializerContext -> obj
Public Function Deserialize (utf8Json As Stream, returnType As Type, context As JsonSerializerContext) As Object

Parameters

utf8Json
Stream

JSON data to parse.

returnType
Type

The type of the object to convert to and return.

context
JsonSerializerContext

A metadata provider for serializable types.

Returns

A returnType representation of the JSON value.

Exceptions

utf8Json, returnType, or context is null.

The JSON is invalid, the returnType is not compatible with the JSON, or there is remaining data in the Stream.

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

The GetTypeInfo(Type) method on the provided context did not return a compatible JsonTypeInfo for returnType.

Applies to

Deserialize(JsonElement, JsonTypeInfo)

Converts the JsonElement representing a single JSON value into an instance specified by the jsonTypeInfo.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Object ^ Deserialize(System::Text::Json::JsonElement element, System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ jsonTypeInfo);
public static object? Deserialize (this System.Text.Json.JsonElement element, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo);
static member Deserialize : System.Text.Json.JsonElement * System.Text.Json.Serialization.Metadata.JsonTypeInfo -> obj
<Extension()>
Public Function Deserialize (element As JsonElement, jsonTypeInfo As JsonTypeInfo) As Object

Parameters

element
JsonElement

The JsonElement to convert.

jsonTypeInfo
JsonTypeInfo

Metadata about the type to convert.

Returns

A jsonTypeInfo representation of the JSON value.

Exceptions

jsonTypeInfo is null.

Applies to

Deserialize<TValue>(Utf8JsonReader, JsonTypeInfo<TValue>)

Reads one JSON value (including objects or arrays) from the provided reader into a TValue.

public:
generic <typename TValue>
 static TValue Deserialize(System::Text::Json::Utf8JsonReader % reader, System::Text::Json::Serialization::Metadata::JsonTypeInfo<TValue> ^ jsonTypeInfo);
public static TValue? Deserialize<TValue> (ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo);
static member Deserialize : Utf8JsonReader * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> -> 'Value
Public Function Deserialize(Of TValue) (ByRef reader As Utf8JsonReader, jsonTypeInfo As JsonTypeInfo(Of TValue)) As TValue

Type Parameters

TValue

The type to deserialize the JSON value into.

Parameters

reader
Utf8JsonReader

The reader to read.

jsonTypeInfo
JsonTypeInfo<TValue>

Metadata about the type to convert.

Returns

TValue

A TValue representation of the JSON value.

Exceptions

The JSON is invalid, TValue is not compatible with the JSON, or a value could not be read from the reader.

reader is using unsupported options.

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

Remarks

If the TokenType property of reader is PropertyName or None, the reader will be advanced by one call to Read() to determine the start of the value.

Upon completion of this method, reader is positioned at the final token in the JSON value. If an exception is thrown, the reader is reset to the state it was in when the method was called.

This method makes a copy of the data the reader acted on, so there is no caller requirement to maintain data integrity beyond the return of this method.

The JsonReaderOptions used to create the instance of the Utf8JsonReader take precedence over the JsonSerializerOptions when they conflict. Hence, AllowTrailingCommas, MaxDepth, and CommentHandling are used while reading.

Applies to

Deserialize<TValue>(JsonDocument, JsonTypeInfo<TValue>)

Converts the JsonDocument representing a single JSON value into a TValue.

public:
generic <typename TValue>
[System::Runtime::CompilerServices::Extension]
 static TValue Deserialize(System::Text::Json::JsonDocument ^ document, System::Text::Json::Serialization::Metadata::JsonTypeInfo<TValue> ^ jsonTypeInfo);
public static TValue? Deserialize<TValue> (this System.Text.Json.JsonDocument document, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo);
static member Deserialize : System.Text.Json.JsonDocument * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> -> 'Value
<Extension()>
Public Function Deserialize(Of TValue) (document As JsonDocument, jsonTypeInfo As JsonTypeInfo(Of TValue)) As TValue

Type Parameters

TValue

The type to deserialize the JSON value into.

Parameters

document
JsonDocument

The JsonDocument to convert.

jsonTypeInfo
JsonTypeInfo<TValue>

Metadata about the type to convert.

Returns

TValue

A TValue representation of the JSON value.

Exceptions

document is null.

-or-

jsonTypeInfo is null.

TValue is not compatible with the JSON.

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

Applies to

Deserialize<TValue>(Utf8JsonReader, JsonSerializerOptions)

Reads one JSON value (including objects or arrays) from the provided reader into an instance of the type specified by a generic type parameter.

public static TValue? Deserialize<TValue> (ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions? options = default);
public static TValue Deserialize<TValue> (ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions options = default);
static member Deserialize : Utf8JsonReader * System.Text.Json.JsonSerializerOptions -> 'Value
Public Shared Function Deserialize(Of TValue) (ByRef reader As Utf8JsonReader, Optional options As JsonSerializerOptions = Nothing) As TValue
Public Function Deserialize(Of TValue) (ByRef reader As Utf8JsonReader, Optional options As JsonSerializerOptions = Nothing) As TValue

Type Parameters

TValue

The target type of the JSON value.

Parameters

reader
Utf8JsonReader

The reader to read the JSON from.

options
JsonSerializerOptions

Options to control serializer behavior during reading.

Returns

TValue

A TValue representation of the JSON value.

Exceptions

The JSON is invalid.

-or-

TValue is not compatible with the JSON.

-or-

A value could not be read from the reader.

reader uses unsupported options.

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

Remarks

If the TokenType property of reader is JsonTokenType.PropertyName or JsonTokenType.None, the reader will be advanced by one call to Utf8JsonReader.Read() to determine the start of the value.

Upon completion of this method, reader will be positioned at the final token in the JSON value. If an exception is thrown, the reader is reset to the state it was in when the method was called.

This method makes a copy of the data the reader acted on, so there is no caller requirement to maintain data integrity beyond the return of this method.

The JsonReaderOptions used to create the instance of the Utf8JsonReader take precedence over the JsonSerializerOptions when they conflict. Hence, JsonReaderOptions.AllowTrailingCommas, JsonReaderOptions.MaxDepth, and JsonReaderOptions.CommentHandling are used while reading.

For more information, see How to serialize and deserialize JSON.

Applies to

Deserialize<TValue>(JsonNode, JsonTypeInfo<TValue>)

Converts the JsonNode representing a single JSON value into a TValue.

public:
generic <typename TValue>
[System::Runtime::CompilerServices::Extension]
 static TValue Deserialize(System::Text::Json::Nodes::JsonNode ^ node, System::Text::Json::Serialization::Metadata::JsonTypeInfo<TValue> ^ jsonTypeInfo);
public static TValue? Deserialize<TValue> (this System.Text.Json.Nodes.JsonNode? node, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo);
static member Deserialize : System.Text.Json.Nodes.JsonNode * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> -> 'Value
<Extension()>
Public Function Deserialize(Of TValue) (node As JsonNode, jsonTypeInfo As JsonTypeInfo(Of TValue)) As TValue

Type Parameters

TValue

The type to deserialize the JSON value into.

Parameters

node
JsonNode

The JsonNode to convert.

jsonTypeInfo
JsonTypeInfo<TValue>

Metadata about the type to convert.

Returns

TValue

A TValue representation of the JSON value.

Exceptions

jsonTypeInfo is null.

TValue is not compatible with the JSON.

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

Applies to

Deserialize<TValue>(JsonNode, JsonSerializerOptions)

Converts the JsonNode representing a single JSON value into a TValue.

public static TValue? Deserialize<TValue> (this System.Text.Json.Nodes.JsonNode? node, System.Text.Json.JsonSerializerOptions? options = default);
static member Deserialize : System.Text.Json.Nodes.JsonNode * System.Text.Json.JsonSerializerOptions -> 'Value
<Extension()>
Public Function Deserialize(Of TValue) (node As JsonNode, Optional options As JsonSerializerOptions = Nothing) As TValue

Type Parameters

TValue

The type to deserialize the JSON value into.

Parameters

node
JsonNode

The JsonNode to convert.

options
JsonSerializerOptions

Options to control the behavior during parsing.

Returns

TValue

A TValue representation of the JSON value.

Exceptions

TValue is not compatible with the JSON.

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

Applies to

Deserialize<TValue>(JsonElement, JsonTypeInfo<TValue>)

Converts the JsonElement representing a single JSON value into a TValue.

public:
generic <typename TValue>
[System::Runtime::CompilerServices::Extension]
 static TValue Deserialize(System::Text::Json::JsonElement element, System::Text::Json::Serialization::Metadata::JsonTypeInfo<TValue> ^ jsonTypeInfo);
public static TValue? Deserialize<TValue> (this System.Text.Json.JsonElement element, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo);
static member Deserialize : System.Text.Json.JsonElement * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> -> 'Value
<Extension()>
Public Function Deserialize(Of TValue) (element As JsonElement, jsonTypeInfo As JsonTypeInfo(Of TValue)) As TValue

Type Parameters

TValue

The type to deserialize the JSON value into.

Parameters

element
JsonElement

The JsonElement to convert.

jsonTypeInfo
JsonTypeInfo<TValue>

Metadata about the type to convert.

Returns

TValue

A TValue representation of the JSON value.

Exceptions

jsonTypeInfo is null.

TValue is not compatible with the JSON.

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

Applies to

Deserialize<TValue>(JsonElement, JsonSerializerOptions)

Converts the JsonElement representing a single JSON value into a TValue.

public static TValue? Deserialize<TValue> (this System.Text.Json.JsonElement element, System.Text.Json.JsonSerializerOptions? options = default);
static member Deserialize : System.Text.Json.JsonElement * System.Text.Json.JsonSerializerOptions -> 'Value
<Extension()>
Public Function Deserialize(Of TValue) (element As JsonElement, Optional options As JsonSerializerOptions = Nothing) As TValue

Type Parameters

TValue

The type to deserialize the JSON value into.

Parameters

element
JsonElement

The JsonElement to convert.

options
JsonSerializerOptions

Options to control the behavior during parsing.

Returns

TValue

A TValue representation of the JSON value.

Exceptions

TValue is not compatible with the JSON.

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

Applies to

Deserialize<TValue>(JsonDocument, JsonSerializerOptions)

Converts the JsonDocument representing a single JSON value into a TValue.

public static TValue? Deserialize<TValue> (this System.Text.Json.JsonDocument document, System.Text.Json.JsonSerializerOptions? options = default);
static member Deserialize : System.Text.Json.JsonDocument * System.Text.Json.JsonSerializerOptions -> 'Value
<Extension()>
Public Function Deserialize(Of TValue) (document As JsonDocument, Optional options As JsonSerializerOptions = Nothing) As TValue

Type Parameters

TValue

The type to deserialize the JSON value into.

Parameters

document
JsonDocument

The JsonDocument to convert.

options
JsonSerializerOptions

Options to control the behavior during parsing.

Returns

TValue

A TValue representation of the JSON value.

Exceptions

document is null.

TValue is not compatible with the JSON.

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

Applies to

Deserialize<TValue>(ReadOnlySpan<Char>, JsonSerializerOptions)

Parses the text representing a single JSON value into an instance of the type specified by a generic type parameter.

public static TValue? Deserialize<TValue> (ReadOnlySpan<char> json, System.Text.Json.JsonSerializerOptions? options = default);
static member Deserialize : ReadOnlySpan<char> * System.Text.Json.JsonSerializerOptions -> 'Value
Public Function Deserialize(Of TValue) (json As ReadOnlySpan(Of Char), Optional options As JsonSerializerOptions = Nothing) As TValue

Type Parameters

TValue

The type to deserialize the JSON value into.

Parameters

json
ReadOnlySpan<Char>

The JSON text to parse.

options
JsonSerializerOptions

Options to control the behavior during parsing.

Returns

TValue

A TValue representation of the JSON value.

Exceptions

The JSON is invalid.

-or-

TValue is not compatible with the JSON.

-or-

There is remaining data in the span beyond a single JSON value.

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

Remarks

Using a UTF-16 span is not as efficient as using the UTF-8 methods since the implementation natively uses UTF-8.

Applies to

Deserialize<TValue>(String, JsonSerializerOptions)

Parses the text representing a single JSON value into an instance of the type specified by a generic type parameter.

public static TValue? Deserialize<TValue> (string json, System.Text.Json.JsonSerializerOptions? options = default);
public static TValue Deserialize<TValue> (string json, System.Text.Json.JsonSerializerOptions options = default);
static member Deserialize : string * System.Text.Json.JsonSerializerOptions -> 'Value
Public Shared Function Deserialize(Of TValue) (json As String, Optional options As JsonSerializerOptions = Nothing) As TValue
Public Function Deserialize(Of TValue) (json As String, Optional options As JsonSerializerOptions = Nothing) As TValue

Type Parameters

TValue

The target type of the JSON value.

Parameters

json
String

The JSON text to parse.

options
JsonSerializerOptions

Options to control the behavior during parsing.

Returns

TValue

A TValue representation of the JSON value.

Exceptions

json is null.

The JSON is invalid.

-or-

TValue is not compatible with the JSON.

-or-

There is remaining data in the string beyond a single JSON value.

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

Remarks

Using a String is not as efficient as using the UTF-8 methods since the implementation natively uses UTF-8.

For more information, see How to serialize and deserialize JSON.

Applies to

Deserialize<TValue>(ReadOnlySpan<Char>, JsonTypeInfo<TValue>)

Parses the text representing a single JSON value into a TValue.

public:
generic <typename TValue>
 static TValue Deserialize(ReadOnlySpan<char> json, System::Text::Json::Serialization::Metadata::JsonTypeInfo<TValue> ^ jsonTypeInfo);
public static TValue? Deserialize<TValue> (ReadOnlySpan<char> json, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo);
static member Deserialize : ReadOnlySpan<char> * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> -> 'Value
Public Function Deserialize(Of TValue) (json As ReadOnlySpan(Of Char), jsonTypeInfo As JsonTypeInfo(Of TValue)) As TValue

Type Parameters

TValue

The type to deserialize the JSON value into.

Parameters

json
ReadOnlySpan<Char>

JSON text to parse.

jsonTypeInfo
JsonTypeInfo<TValue>

Metadata about the type to convert.

Returns

TValue

A TValue representation of the JSON value.

Exceptions

json is null.

-or-

jsonTypeInfo is null.

The JSON is invalid.

-or-

TValue is not compatible with the JSON.

-or-

There is remaining data in the string beyond a single JSON value.

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

Remarks

Using a String is not as efficient as using the UTF-8 methods since the implementation natively uses UTF-8.

Applies to

Deserialize<TValue>(ReadOnlySpan<Byte>, JsonTypeInfo<TValue>)

Parses the UTF-8 encoded text representing a single JSON value into a TValue.

public:
generic <typename TValue>
 static TValue Deserialize(ReadOnlySpan<System::Byte> utf8Json, System::Text::Json::Serialization::Metadata::JsonTypeInfo<TValue> ^ jsonTypeInfo);
public static TValue? Deserialize<TValue> (ReadOnlySpan<byte> utf8Json, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo);
static member Deserialize : ReadOnlySpan<byte> * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> -> 'Value
Public Function Deserialize(Of TValue) (utf8Json As ReadOnlySpan(Of Byte), jsonTypeInfo As JsonTypeInfo(Of TValue)) As TValue

Type Parameters

TValue

The type to deserialize the JSON value into.

Parameters

utf8Json
ReadOnlySpan<Byte>

JSON text to parse.

jsonTypeInfo
JsonTypeInfo<TValue>

Metadata about the type to convert.

Returns

TValue

A TValue representation of the JSON value.

Exceptions

The JSON is invalid, TValue is not compatible with the JSON, or there is remaining data in the Stream.

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

Applies to

Deserialize<TValue>(ReadOnlySpan<Byte>, JsonSerializerOptions)

Parses the UTF-8 encoded text representing a single JSON value into an instance of the type specified by a generic type parameter.

public static TValue? Deserialize<TValue> (ReadOnlySpan<byte> utf8Json, System.Text.Json.JsonSerializerOptions? options = default);
public static TValue Deserialize<TValue> (ReadOnlySpan<byte> utf8Json, System.Text.Json.JsonSerializerOptions options = default);
static member Deserialize : ReadOnlySpan<byte> * System.Text.Json.JsonSerializerOptions -> 'Value
Public Shared Function Deserialize(Of TValue) (utf8Json As ReadOnlySpan(Of Byte), Optional options As JsonSerializerOptions = Nothing) As TValue
Public Function Deserialize(Of TValue) (utf8Json As ReadOnlySpan(Of Byte), Optional options As JsonSerializerOptions = Nothing) As TValue

Type Parameters

TValue

The target type of the UTF-8 encoded text.

Parameters

utf8Json
ReadOnlySpan<Byte>

The JSON text to parse.

options
JsonSerializerOptions

Options to control the behavior during parsing.

Returns

TValue

A TValue representation of the JSON value.

Exceptions

The JSON is invalid.

-or-

TValue is not compatible with the JSON.

-or-

There is remaining data in the span beyond a single JSON value.

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

Remarks

For more information, see How to serialize and deserialize JSON.

Applies to

Deserialize<TValue>(Stream, JsonTypeInfo<TValue>)

Reads the UTF-8 encoded text representing a single JSON value into a TValue. The Stream will be read to completion.

public:
generic <typename TValue>
 static TValue Deserialize(System::IO::Stream ^ utf8Json, System::Text::Json::Serialization::Metadata::JsonTypeInfo<TValue> ^ jsonTypeInfo);
public static TValue? Deserialize<TValue> (System.IO.Stream utf8Json, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo);
static member Deserialize : System.IO.Stream * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> -> 'Value
Public Function Deserialize(Of TValue) (utf8Json As Stream, jsonTypeInfo As JsonTypeInfo(Of TValue)) As TValue

Type Parameters

TValue

The type to deserialize the JSON value into.

Parameters

utf8Json
Stream

JSON data to parse.

jsonTypeInfo
JsonTypeInfo<TValue>

Metadata about the type to convert.

Returns

TValue

A TValue representation of the JSON value.

Exceptions

utf8Json or jsonTypeInfo is null.

The JSON is invalid, TValue is not compatible with the JSON, or there is remaining data in the Stream.

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

Applies to

Deserialize<TValue>(Stream, JsonSerializerOptions)

Reads the UTF-8 encoded text representing a single JSON value into a TValue. The Stream will be read to completion.

public static TValue? Deserialize<TValue> (System.IO.Stream utf8Json, System.Text.Json.JsonSerializerOptions? options = default);
static member Deserialize : System.IO.Stream * System.Text.Json.JsonSerializerOptions -> 'Value
Public Function Deserialize(Of TValue) (utf8Json As Stream, Optional options As JsonSerializerOptions = Nothing) As TValue

Type Parameters

TValue

The type to deserialize the JSON value into.

Parameters

utf8Json
Stream

JSON data to parse.

options
JsonSerializerOptions

Options to control the behavior during reading.

Returns

TValue

A TValue representation of the JSON value.

Exceptions

utf8Json is null.

The JSON is invalid, TValue is not compatible with the JSON, or there is remaining data in the Stream.

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

Applies to

Deserialize<TValue>(String, JsonTypeInfo<TValue>)

Parses the text representing a single JSON value into a TValue.

public:
generic <typename TValue>
 static TValue Deserialize(System::String ^ json, System::Text::Json::Serialization::Metadata::JsonTypeInfo<TValue> ^ jsonTypeInfo);
public static TValue? Deserialize<TValue> (string json, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo);
static member Deserialize : string * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> -> 'Value
Public Function Deserialize(Of TValue) (json As String, jsonTypeInfo As JsonTypeInfo(Of TValue)) As TValue

Type Parameters

TValue

The type to deserialize the JSON value into.

Parameters

json
String

JSON text to parse.

jsonTypeInfo
JsonTypeInfo<TValue>

Metadata about the type to convert.

Returns

TValue

A TValue representation of the JSON value.

Exceptions

json is null.

-or-

jsonTypeInfo is null.

The JSON is invalid.

-or-

TValue is not compatible with the JSON.

-or-

There is remaining data in the string beyond a single JSON value.

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

Remarks

Using a String is not as efficient as using the UTF-8 methods since the implementation natively uses UTF-8.

Applies to