JsonSerializer.Deserialize 方法

定义

重载

Deserialize(Stream, JsonTypeInfo)

将表示单个 JSON 值的 UTF-8 编码文本读入由 指定的实例中 jsonTypeInfo。 流将读取到完成。

Deserialize(Utf8JsonReader, Type, JsonSerializerContext)

读取一个 JSON 值, (包括从提供的读取器) 的对象或数组。returnType

Deserialize(Utf8JsonReader, Type, JsonSerializerOptions)

读取一个 JSON 值, (包括从提供的读取器) 的对象或数组,并将其转换为指定类型的实例。

Deserialize(JsonNode, Type, JsonSerializerOptions)

JsonNode 表示单个 JSON 值的 转换为 returnType

Deserialize(JsonElement, Type, JsonSerializerContext)

JsonElement 表示单个 JSON 值的 转换为 returnType

Deserialize(JsonElement, Type, JsonSerializerOptions)

JsonElement 表示单个 JSON 值的 转换为 returnType

Deserialize(JsonDocument, Type, JsonSerializerContext)

JsonDocument 表示单个 JSON 值的 转换为 returnType

Deserialize(JsonDocument, Type, JsonSerializerOptions)

JsonDocument 表示单个 JSON 值的 转换为 returnType

Deserialize(String, Type, JsonSerializerContext)

将表示单个 JSON 值的文本分析为 returnType

Deserialize(String, Type, JsonSerializerOptions)

将表示单个 JSON 值的文本分析为指定类型的实例。

Deserialize(ReadOnlySpan<Char>, Type, JsonSerializerContext)

将表示单个 JSON 值的文本分析为 returnType

Deserialize(ReadOnlySpan<Char>, Type, JsonSerializerOptions)

将表示单个 JSON 值的文本分析为指定类型的实例。

Deserialize(JsonNode, Type, JsonSerializerContext)

JsonNode 表示单个 JSON 值的 转换为 returnType

Deserialize(ReadOnlySpan<Byte>, Type, JsonSerializerOptions)

将表示单个 JSON 值的 UTF-8 编码文本分析为指定类型的实例。

Deserialize(ReadOnlySpan<Byte>, Type, JsonSerializerContext)

将表示单个 JSON 值的 UTF-8 编码文本分析为 returnType

Deserialize(ReadOnlySpan<Byte>, JsonTypeInfo)

将表示单个 JSON 值的 UTF-8 编码文本分析为 指定的 jsonTypeInfo实例。

Deserialize(String, JsonTypeInfo)

将表示单个 JSON 值的文本分析为 指定的 jsonTypeInfo实例。

Deserialize(JsonDocument, JsonTypeInfo)

JsonDocument 表示单个 JSON 值的 转换为由 jsonTypeInfo指定的实例。

Deserialize(ReadOnlySpan<Char>, JsonTypeInfo)

将表示单个 JSON 值的文本分析为 指定的 jsonTypeInfo实例。

Deserialize(JsonNode, JsonTypeInfo)

JsonNode 表示单个 JSON 值的 转换为由 jsonTypeInfo指定的实例。

Deserialize(Utf8JsonReader, JsonTypeInfo)

将一个 JSON 值 (从提供的读取器) 对象或数组读取到 指定的实例中 jsonTypeInfo

Deserialize(Stream, Type, JsonSerializerOptions)

将表示单个 JSON 值的 UTF-8 编码文本读入 returnType。 流将读取到完成。

Deserialize(Stream, Type, JsonSerializerContext)

将表示单个 JSON 值的 UTF-8 编码文本读入 returnType。 流将读取到完成。

Deserialize(JsonElement, JsonTypeInfo)

JsonElement 表示单个 JSON 值的 转换为由 jsonTypeInfo指定的实例。

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

读取一个 JSON 值, (包括从提供的读取器) 的对象或数组。TValue

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

JsonDocument 表示单个 JSON 值的 转换为 TValue

Deserialize<TValue>(Utf8JsonReader, JsonSerializerOptions)

将一个 JSON 值(包括对象或数组)从提供的读取器读取到泛型类型参数指定的类型的实例中。

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

JsonNode 表示单个 JSON 值的 转换为 TValue

Deserialize<TValue>(JsonNode, JsonSerializerOptions)

JsonNode 表示单个 JSON 值的 转换为 TValue

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

JsonElement 表示单个 JSON 值的 转换为 TValue

Deserialize<TValue>(JsonElement, JsonSerializerOptions)

JsonElement 表示单个 JSON 值的 转换为 TValue

Deserialize<TValue>(JsonDocument, JsonSerializerOptions)

JsonDocument 表示单个 JSON 值的 转换为 TValue

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

将表示单个 JSON 值的文本分析为泛型类型参数指定的类型的实例。

Deserialize<TValue>(String, JsonSerializerOptions)

将表示单个 JSON 值的文本分析为泛型类型参数指定的类型的实例。

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

将表示单个 JSON 值的文本分析为 TValue

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

将表示单个 JSON 值的 UTF-8 编码文本分析为 TValue

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

将表示单个 JSON 值的 UTF-8 编码文本分析为泛型类型参数指定的类型的实例。

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

将表示单个 JSON 值的 UTF-8 编码文本读入 TValue。 流将读取到完成。

Deserialize<TValue>(Stream, JsonSerializerOptions)

将表示单个 JSON 值的 UTF-8 编码文本读入 TValue。 流将读取到完成。

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

将表示单个 JSON 值的文本分析为 TValue

Deserialize(Stream, JsonTypeInfo)

Source:
JsonSerializer.Read.Stream.cs
Source:
JsonSerializer.Read.Stream.cs

将表示单个 JSON 值的 UTF-8 编码文本读入由 指定的实例中 jsonTypeInfo。 流将读取到完成。

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

参数

utf8Json
Stream

要分析的 JSON 数据。

jsonTypeInfo
JsonTypeInfo

有关要转换的类型的元数据。

返回

JSON 值的 jsonTypeInfo 表示。

例外

utf8JsonjsonTypeInfonull

JSON 无效,或者流中存在剩余数据。

适用于

Deserialize(Utf8JsonReader, Type, JsonSerializerContext)

Source:
JsonSerializer.Read.Utf8JsonReader.cs
Source:
JsonSerializer.Read.Utf8JsonReader.cs
Source:
JsonSerializer.Read.Utf8JsonReader.cs

读取一个 JSON 值, (包括从提供的读取器) 的对象或数组。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

参数

reader
Utf8JsonReader

要用于读取的读取器。

returnType
Type

要转换为并返回的对象的类型。

context
JsonSerializerContext

可序列化类型的元数据提供程序。

返回

JSON 值的 returnType 表示。

例外

returnTypecontextnull

Json 无效,returnType 与 JSON 不兼容,或者无法从读取器读取值。

reader 使用的是不受支持的选项。

returnType 或其可序列化成员没有兼容的 JsonConverter

GetTypeInfo(Type)提供的 context 上的 方法未返回与 returnType兼容的 JsonTypeInfo

注解

TokenType如果 的 reader 属性为 PropertyNameNone,则读取器将通过对 的一次调用Read()来提前确定值的开头。

此方法完成后, reader 位于 JSON 值中的最终标记处。 如果引发异常,读取器将重置为调用 方法时处于的状态。

此方法创建读取器操作的数据的副本,因此除了此方法的返回之外,调用方不需要维护数据完整性。

JsonReaderOptions用于创建 实例的 Utf8JsonReader 在发生冲突时优先于 JsonSerializerOptions 。 因此,读取 AllowTrailingCommas时使用 、 MaxDepthCommentHandling

适用于

Deserialize(Utf8JsonReader, Type, JsonSerializerOptions)

Source:
JsonSerializer.Read.Utf8JsonReader.cs
Source:
JsonSerializer.Read.Utf8JsonReader.cs
Source:
JsonSerializer.Read.Utf8JsonReader.cs

读取一个 JSON 值, (包括从提供的读取器) 的对象或数组,并将其转换为指定类型的实例。

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

参数

reader
Utf8JsonReader

要从中读取 JSON 的读取器。

returnType
Type

要转换为并返回的对象的类型。

options
JsonSerializerOptions

读取期间用于控制序列化程序行为的选项。

返回

JSON 值的 returnType 表示。

例外

returnTypenull

JSON 无效。

- 或 -

returnType 与 JSON 不兼容。

- 或 -

无法从读取器中读取值。

reader 使用的是不受支持的选项。

returnType 或其可序列化成员没有兼容的 JsonConverter

注解

TokenType如果 的 reader 属性为 JsonTokenType.PropertyNameJsonTokenType.None,则读取器将通过对 的一次调用Utf8JsonReader.Read()来提前确定值的开头。

完成此方法后, reader 将定位在 JSON 值中的最终标记处。 如果引发异常,读取器将重置为调用 方法时处于的状态。

此方法创建读取器操作的数据的副本,因此除了此方法的返回之外,调用方不需要维护数据完整性。

JsonReaderOptions用于创建 实例的 Utf8JsonReader 在发生冲突时优先于 JsonSerializerOptions 。 因此,读取 JsonReaderOptions.AllowTrailingCommas时使用 、 JsonReaderOptions.MaxDepthJsonReaderOptions.CommentHandling

有关详细信息,请参阅 如何序列化和反序列化 JSON

适用于

Deserialize(JsonNode, Type, JsonSerializerOptions)

Source:
JsonSerializer.Read.Node.cs
Source:
JsonSerializer.Read.Node.cs
Source:
JsonSerializer.Read.Node.cs

JsonNode 表示单个 JSON 值的 转换为 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

参数

node
JsonNode

要转换的 JsonNode

returnType
Type

要转换为并返回的对象的类型。

options
JsonSerializerOptions

分析期间用于控制行为的选项。

返回

JSON 值的 returnType 表示。

例外

returnType 与 JSON 不兼容。

returnType 或其可序列化成员没有兼容的 JsonConverter

适用于

Deserialize(JsonElement, Type, JsonSerializerContext)

Source:
JsonSerializer.Read.Element.cs
Source:
JsonSerializer.Read.Element.cs
Source:
JsonSerializer.Read.Element.cs

JsonElement 表示单个 JSON 值的 转换为 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

参数

element
JsonElement

要转换的 JsonElement

returnType
Type

要转换为并返回的对象的类型。

context
JsonSerializerContext

可序列化类型的元数据提供程序。

返回

JSON 值的 returnType 表示。

例外

returnTypenull

contextnull

JSON 无效。

- 或 -

returnType 与 JSON 不兼容。

- 或 -

单个 JSON 值以外的字符串中存在剩余数据。

returnType 或其可序列化成员没有兼容的 JsonConverter

GetTypeInfo(Type)提供的 context 的 方法返回null要转换的类型。

适用于

Deserialize(JsonElement, Type, JsonSerializerOptions)

Source:
JsonSerializer.Read.Element.cs
Source:
JsonSerializer.Read.Element.cs
Source:
JsonSerializer.Read.Element.cs

JsonElement 表示单个 JSON 值的 转换为 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

参数

element
JsonElement

要转换的 JsonElement

returnType
Type

要转换为并返回的对象的类型。

options
JsonSerializerOptions

分析期间用于控制行为的选项。

返回

JSON 值的 returnType 表示。

例外

returnTypenull

returnType 与 JSON 不兼容。

returnType 或其可序列化成员没有兼容的 JsonConverter

适用于

Deserialize(JsonDocument, Type, JsonSerializerContext)

Source:
JsonSerializer.Read.Document.cs
Source:
JsonSerializer.Read.Document.cs
Source:
JsonSerializer.Read.Document.cs

JsonDocument 表示单个 JSON 值的 转换为 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

参数

document
JsonDocument

要转换的 JsonDocument

returnType
Type

要转换为并返回的对象的类型。

context
JsonSerializerContext

可序列化类型的元数据提供程序。

返回

JSON 值的 returnType 表示。

例外

documentnull

returnTypenull

contextnull

JSON 无效。

- 或 -

returnType 与 JSON 不兼容。

- 或 -

单个 JSON 值以外的字符串中存在剩余数据。

returnType 或其可序列化成员没有兼容的 JsonConverter

GetTypeInfo(Type)提供的 context 的 方法返回null要转换的类型。

适用于

Deserialize(JsonDocument, Type, JsonSerializerOptions)

Source:
JsonSerializer.Read.Document.cs
Source:
JsonSerializer.Read.Document.cs
Source:
JsonSerializer.Read.Document.cs

JsonDocument 表示单个 JSON 值的 转换为 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

参数

document
JsonDocument

要转换的 JsonDocument

returnType
Type

要转换为并返回的对象的类型。

options
JsonSerializerOptions

分析期间用于控制行为的选项。

返回

JSON 值的 returnType 表示。

例外

documentreturnTypenull

returnType 与 JSON 不兼容。

returnType 或其可序列化成员没有兼容的 JsonConverter

适用于

Deserialize(String, Type, JsonSerializerContext)

Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs

将表示单个 JSON 值的文本分析为 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

参数

json
String

要分析的 JSON 文本。

returnType
Type

要转换为并返回的对象的类型。

context
JsonSerializerContext

可序列化类型的元数据提供程序。

返回

JSON 值的 returnType 表示。

例外

jsonreturnTypenull

- 或 -

contextnull

JSON 无效。

- 或 -

returnType 与 JSON 不兼容。

- 或 -

单个 JSON 值以外的字符串中存在剩余数据。

returnType 或其可序列化成员没有兼容的 JsonConverter

GetTypeInfo(Type)提供的 context 的 方法返回null要转换的类型。

注解

String使用 不如使用 UTF-8 方法高效,因为实现本机使用 UTF-8。

适用于

Deserialize(String, Type, JsonSerializerOptions)

Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs

将表示单个 JSON 值的文本分析为指定类型的实例。

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

参数

json
String

要分析的 JSON 文本。

returnType
Type

要转换为并返回的对象的类型。

options
JsonSerializerOptions

分析期间用于控制行为的选项。

返回

JSON 值的 returnType 表示。

例外

jsonreturnTypenull

JSON 无效。

- 或 -

TValue 与 JSON 不兼容。

- 或 -

单个 JSON 值以外的字符串中存在剩余数据。

returnType 或其可序列化成员没有兼容的 JsonConverter

注解

String使用 不如使用 UTF-8 方法高效,因为实现本机使用 UTF-8。

有关详细信息,请参阅 如何序列化和反序列化 JSON

适用于

Deserialize(ReadOnlySpan<Char>, Type, JsonSerializerContext)

Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs

将表示单个 JSON 值的文本分析为 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

参数

json
ReadOnlySpan<Char>

要分析的 JSON 文本。

returnType
Type

要转换为并返回的对象的类型。

context
JsonSerializerContext

可序列化类型的元数据提供程序。

返回

JSON 值的 returnType 表示。

例外

jsonreturnTypenull

- 或 -

contextnull

JSON 无效。

- 或 -

returnType 与 JSON 不兼容。

- 或 -

单个 JSON 值以外的字符串中存在剩余数据。

returnType 或其可序列化成员没有兼容的 JsonConverter

GetTypeInfo(Type)提供的 context 方法返回null要转换的类型。

注解

String使用 不如使用 UTF-8 方法高效,因为实现本机使用 UTF-8。

适用于

Deserialize(ReadOnlySpan<Char>, Type, JsonSerializerOptions)

Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs

将表示单个 JSON 值的文本分析为指定类型的实例。

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

参数

json
ReadOnlySpan<Char>

要分析的 JSON 文本。

returnType
Type

要转换为并返回的对象的类型。

options
JsonSerializerOptions

分析期间用于控制行为的选项。

返回

JSON 值的 returnType 表示。

例外

returnTypenull

JSON 无效。

- 或 -

returnType 与 JSON 不兼容。

- 或 -

单个 JSON 值以外的跨度中存在剩余数据。

returnType 或其可序列化成员没有兼容的 JsonConverter

注解

使用 UTF-16 范围不如使用 UTF-8 方法高效,因为实现本机使用 UTF-8。

适用于

Deserialize(JsonNode, Type, JsonSerializerContext)

Source:
JsonSerializer.Read.Node.cs
Source:
JsonSerializer.Read.Node.cs
Source:
JsonSerializer.Read.Node.cs

JsonNode 表示单个 JSON 值的 转换为 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

参数

node
JsonNode

要转换的 JsonNode

returnType
Type

要转换为并返回的对象的类型。

context
JsonSerializerContext

可序列化类型的元数据提供程序。

返回

JSON 值的 returnType 表示。

例外

returnTypenull

contextnull

JSON 无效。

- 或 -

returnType 与 JSON 不兼容。

- 或 -

单个 JSON 值以外的字符串中存在剩余数据。

returnType 或其可序列化成员没有兼容的 JsonConverter

GetTypeInfo(Type)提供的 context 方法返回null要转换的类型。

适用于

Deserialize(ReadOnlySpan<Byte>, Type, JsonSerializerOptions)

Source:
JsonSerializer.Read.Span.cs
Source:
JsonSerializer.Read.Span.cs
Source:
JsonSerializer.Read.Span.cs

将表示单个 JSON 值的 UTF-8 编码文本分析为指定类型的实例。

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

参数

utf8Json
ReadOnlySpan<Byte>

要分析的 JSON 文本。

returnType
Type

要转换为并返回的对象的类型。

options
JsonSerializerOptions

分析期间用于控制行为的选项。

返回

JSON 值的 returnType 表示。

例外

returnTypenull

JSON 无效。

- 或 -

returnType 与 JSON 不兼容。

- 或 -

单个 JSON 值以外的跨度中存在剩余数据。

returnType 或其可序列化成员没有兼容的 JsonConverter

注解

有关详细信息,请参阅 如何序列化和反序列化 JSON

适用于

Deserialize(ReadOnlySpan<Byte>, Type, JsonSerializerContext)

Source:
JsonSerializer.Read.Span.cs
Source:
JsonSerializer.Read.Span.cs
Source:
JsonSerializer.Read.Span.cs

将表示单个 JSON 值的 UTF-8 编码文本分析为 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

参数

utf8Json
ReadOnlySpan<Byte>

要分析的 JSON 文本。

returnType
Type

要转换为并返回的对象的类型。

context
JsonSerializerContext

可序列化类型的元数据提供程序。

返回

JSON 值的 returnType 表示。

例外

returnTypenull

JSON 无效、 returnType 与 JSON 不兼容,或者流中存在剩余数据。

returnType 或其可序列化成员没有兼容的 JsonConverter

GetTypeInfo(Type)提供的 context 上的 方法未返回与 returnType兼容的 JsonTypeInfo

适用于

Deserialize(ReadOnlySpan<Byte>, JsonTypeInfo)

Source:
JsonSerializer.Read.Span.cs
Source:
JsonSerializer.Read.Span.cs

将表示单个 JSON 值的 UTF-8 编码文本分析为 指定的 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

参数

utf8Json
ReadOnlySpan<Byte>

要分析的 JSON 文本。

jsonTypeInfo
JsonTypeInfo

有关要转换的类型的元数据。

返回

JSON 值的 jsonTypeInfo 表示。

例外

JSON 无效,或者缓冲区中存在剩余数据。

适用于

Deserialize(String, JsonTypeInfo)

Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs

将表示单个 JSON 值的文本分析为 指定的 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

参数

json
String

要分析的 JSON 文本。

jsonTypeInfo
JsonTypeInfo

有关要转换的类型的元数据。

返回

JSON 值的 jsonTypeInfo 表示。

例外

jsonnull

jsonTypeInfonull

JSON 无效。

- 或 -

单个 JSON 值以外的字符串中存在剩余数据。

注解

String使用 不如使用 UTF-8 方法高效,因为实现本机使用 UTF-8。

适用于

Deserialize(JsonDocument, JsonTypeInfo)

Source:
JsonSerializer.Read.Document.cs
Source:
JsonSerializer.Read.Document.cs

JsonDocument 表示单个 JSON 值的 转换为 由 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

参数

document
JsonDocument

要转换的 JsonDocument

jsonTypeInfo
JsonTypeInfo

有关要转换的类型的元数据。

返回

JSON 值的 jsonTypeInfo 表示。

例外

documentnull

jsonTypeInfonull

适用于

Deserialize(ReadOnlySpan<Char>, JsonTypeInfo)

Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs

将表示单个 JSON 值的文本分析为 指定的 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

参数

json
ReadOnlySpan<Char>

要分析的 JSON 文本。

jsonTypeInfo
JsonTypeInfo

有关要转换的类型的元数据。

返回

JSON 值的 jsonTypeInfo 表示。

例外

jsonTypeInfonull

JSON 无效。

- 或 -

单个 JSON 值以外的字符串中存在剩余数据。

注解

String使用 不如使用 UTF-8 方法高效,因为实现本机使用 UTF-8。

适用于

Deserialize(JsonNode, JsonTypeInfo)

Source:
JsonSerializer.Read.Node.cs
Source:
JsonSerializer.Read.Node.cs

JsonNode 表示单个 JSON 值的 转换为 由 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

参数

node
JsonNode

要转换的 JsonNode

jsonTypeInfo
JsonTypeInfo

有关要转换的类型的元数据。

返回

JSON 值的 jsonTypeInfo 表示。

例外

jsonTypeInfonull

适用于

Deserialize(Utf8JsonReader, JsonTypeInfo)

Source:
JsonSerializer.Read.Utf8JsonReader.cs
Source:
JsonSerializer.Read.Utf8JsonReader.cs

将一个 JSON 值 (包括从提供的读取器) 的对象或数组读入指定的实例中 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

参数

reader
Utf8JsonReader

要用于读取的读取器。

jsonTypeInfo
JsonTypeInfo

有关要转换的类型的元数据。

返回

JSON 值的 jsonTypeInfo 表示。

例外

Json 无效,jsonTypeInfo 与 JSON 不兼容,或者无法从读取器读取值。

reader 使用的是不受支持的选项。

注解

TokenType如果 的 reader 属性为 PropertyNameNone,则读取器将通过对 的一次调用Read()来提前确定值的开头。

完成此方法后, reader 将定位在 JSON 值中的最终标记处。 如果引发异常,读取器将重置为调用 方法时处于的状态。

此方法会复制读取者处理的数据,因此,除了此方法的返回之外,调用方不需要维护数据完整性。

JsonReaderOptions用于创建 实例的 Utf8JsonReader 在发生冲突时优先于 JsonSerializerOptions 。 因此, AllowTrailingCommas读取时会使用 、 MaxDepthCommentHandling

适用于

Deserialize(Stream, Type, JsonSerializerOptions)

Source:
JsonSerializer.Read.Stream.cs
Source:
JsonSerializer.Read.Stream.cs
Source:
JsonSerializer.Read.Stream.cs

将表示单个 JSON 值的 UTF-8 编码文本读入 。returnType 流将被读取到完成。

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

参数

utf8Json
Stream

要分析的 JSON 数据。

returnType
Type

要转换为并返回的对象的类型。

options
JsonSerializerOptions

读取期间用于控制行为的选项。

返回

JSON 值的 returnType 表示。

例外

utf8JsonreturnTypenull

JSON 无效,与 returnType JSON 不兼容,或者流中存在剩余数据。

returnType 或其可序列化成员没有兼容的 JsonConverter

适用于

Deserialize(Stream, Type, JsonSerializerContext)

Source:
JsonSerializer.Read.Stream.cs
Source:
JsonSerializer.Read.Stream.cs
Source:
JsonSerializer.Read.Stream.cs

将表示单个 JSON 值的 UTF-8 编码文本读入 。returnType 流将被读取到完成。

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

参数

utf8Json
Stream

要分析的 JSON 数据。

returnType
Type

要转换为并返回的对象的类型。

context
JsonSerializerContext

可序列化类型的元数据提供程序。

返回

JSON 值的 returnType 表示。

例外

utf8JsonreturnTypecontextnull

JSON 无效,与 returnType JSON 不兼容,或者流中存在剩余数据。

returnType 或其可序列化成员没有兼容的 JsonConverter

GetTypeInfo(Type)提供的 context 上的 方法未返回与 returnType兼容的 JsonTypeInfo

适用于

Deserialize(JsonElement, JsonTypeInfo)

Source:
JsonSerializer.Read.Element.cs
Source:
JsonSerializer.Read.Element.cs

JsonElement 表示单个 JSON 值的 转换为 由 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

参数

element
JsonElement

要转换的 JsonElement

jsonTypeInfo
JsonTypeInfo

有关要转换的类型的元数据。

返回

JSON 值的 jsonTypeInfo 表示。

例外

jsonTypeInfonull

适用于

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

Source:
JsonSerializer.Read.Utf8JsonReader.cs
Source:
JsonSerializer.Read.Utf8JsonReader.cs
Source:
JsonSerializer.Read.Utf8JsonReader.cs

读取一个 JSON 值, (包括从提供的读取器) 的对象或数组到 中 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

类型参数

TValue

要反序列化 JSON 值的类型。

参数

reader
Utf8JsonReader

要用于读取的读取器。

jsonTypeInfo
JsonTypeInfo<TValue>

有关要转换的类型的元数据。

返回

TValue

JSON 值的 TValue 表示。

例外

Json 无效,TValue 与 JSON 不兼容,或者无法从读取器读取值。

reader 使用的是不受支持的选项。

TValue 或其可序列化成员没有兼容的 JsonConverter

注解

TokenType如果 的 reader 属性为 PropertyNameNone,则读取器将通过对 的一次调用Read()来提前确定值的开头。

完成此方法后, reader 位于 JSON 值中的最终标记处。 如果引发异常,读取器将重置为调用 方法时处于的状态。

此方法会复制读取者处理的数据,因此,除了此方法的返回之外,调用方不需要维护数据完整性。

JsonReaderOptions用于创建 实例的 Utf8JsonReader 在发生冲突时优先于 JsonSerializerOptions 。 因此, AllowTrailingCommas读取时会使用 、 MaxDepthCommentHandling

适用于

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

Source:
JsonSerializer.Read.Document.cs
Source:
JsonSerializer.Read.Document.cs
Source:
JsonSerializer.Read.Document.cs

JsonDocument 表示单个 JSON 值的 转换为 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

类型参数

TValue

要反序列化 JSON 值的类型。

参数

document
JsonDocument

要转换的 JsonDocument

jsonTypeInfo
JsonTypeInfo<TValue>

有关要转换的类型的元数据。

返回

TValue

JSON 值的 TValue 表示。

例外

documentnull

jsonTypeInfonull

TValue 与 JSON 不兼容。

TValue 或其可序列化成员没有兼容的 JsonConverter

适用于

Deserialize<TValue>(Utf8JsonReader, JsonSerializerOptions)

Source:
JsonSerializer.Read.Utf8JsonReader.cs
Source:
JsonSerializer.Read.Utf8JsonReader.cs
Source:
JsonSerializer.Read.Utf8JsonReader.cs

将一个 JSON 值(包括对象或数组)从提供的读取器读取到泛型类型参数指定的类型的实例中。

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

类型参数

TValue

JSON 值的目标类型。

参数

reader
Utf8JsonReader

要从中读取 JSON 的读取器。

options
JsonSerializerOptions

读取期间用于控制序列化程序行为的选项。

返回

TValue

JSON 值的 TValue 表示。

例外

JSON 无效。

- 或 -

TValue 与 JSON 不兼容。

- 或 -

无法从读取器中读取值。

reader 不受支持的选项。

TValue 或其可序列化成员没有兼容的 JsonConverter

注解

TokenType如果 的 reader 属性为 JsonTokenType.PropertyNameJsonTokenType.None,则读取器将通过对 的一次调用Utf8JsonReader.Read()来提前确定值的开头。

完成此方法后, reader 将定位在 JSON 值中的最终标记处。 如果引发异常,读取器将重置为调用 方法时处于的状态。

此方法会复制读取者处理的数据,因此,除了此方法的返回之外,调用方不需要维护数据完整性。

JsonReaderOptions用于创建 实例的 Utf8JsonReader 在发生冲突时优先于 JsonSerializerOptions 。 因此, JsonReaderOptions.AllowTrailingCommas读取时会使用 、 JsonReaderOptions.MaxDepthJsonReaderOptions.CommentHandling

有关详细信息,请参阅 如何序列化和反序列化 JSON

适用于

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

Source:
JsonSerializer.Read.Node.cs
Source:
JsonSerializer.Read.Node.cs
Source:
JsonSerializer.Read.Node.cs

JsonNode 表示单个 JSON 值的 转换为 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

类型参数

TValue

要反序列化 JSON 值的类型。

参数

node
JsonNode

要转换的 JsonNode

jsonTypeInfo
JsonTypeInfo<TValue>

有关要转换的类型的元数据。

返回

TValue

JSON 值的 TValue 表示。

例外

jsonTypeInfonull

TValue 与 JSON 不兼容。

TValue 或其可序列化成员没有兼容的 JsonConverter

适用于

Deserialize<TValue>(JsonNode, JsonSerializerOptions)

Source:
JsonSerializer.Read.Node.cs
Source:
JsonSerializer.Read.Node.cs
Source:
JsonSerializer.Read.Node.cs

JsonNode 表示单个 JSON 值的 转换为 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

类型参数

TValue

要反序列化 JSON 值的类型。

参数

node
JsonNode

要转换的 JsonNode

options
JsonSerializerOptions

分析期间用于控制行为的选项。

返回

TValue

JSON 值的 TValue 表示。

例外

TValue 与 JSON 不兼容。

TValue 或其可序列化成员没有兼容的 JsonConverter

适用于

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

Source:
JsonSerializer.Read.Element.cs
Source:
JsonSerializer.Read.Element.cs
Source:
JsonSerializer.Read.Element.cs

JsonElement 表示单个 JSON 值的 转换为 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

类型参数

TValue

要反序列化 JSON 值的类型。

参数

element
JsonElement

要转换的 JsonElement

jsonTypeInfo
JsonTypeInfo<TValue>

有关要转换的类型的元数据。

返回

TValue

JSON 值的 TValue 表示。

例外

jsonTypeInfonull

TValue 与 JSON 不兼容。

TValue 或其可序列化成员没有兼容的 JsonConverter

适用于

Deserialize<TValue>(JsonElement, JsonSerializerOptions)

Source:
JsonSerializer.Read.Element.cs
Source:
JsonSerializer.Read.Element.cs
Source:
JsonSerializer.Read.Element.cs

JsonElement 表示单个 JSON 值的 转换为 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

类型参数

TValue

要反序列化 JSON 值的类型。

参数

element
JsonElement

要转换的 JsonElement

options
JsonSerializerOptions

分析期间用于控制行为的选项。

返回

TValue

JSON 值的 TValue 表示。

例外

TValue 与 JSON 不兼容。

TValue 或其可序列化成员没有兼容的 JsonConverter

适用于

Deserialize<TValue>(JsonDocument, JsonSerializerOptions)

Source:
JsonSerializer.Read.Document.cs
Source:
JsonSerializer.Read.Document.cs
Source:
JsonSerializer.Read.Document.cs

JsonDocument 表示单个 JSON 值的 转换为 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

类型参数

TValue

要反序列化 JSON 值的类型。

参数

document
JsonDocument

要转换的 JsonDocument

options
JsonSerializerOptions

分析期间用于控制行为的选项。

返回

TValue

JSON 值的 TValue 表示。

例外

documentnull

TValue 与 JSON 不兼容。

TValue 或其可序列化成员没有兼容的 JsonConverter

适用于

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

Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs

将表示单个 JSON 值的文本分析为泛型类型参数指定的类型的实例。

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

类型参数

TValue

要反序列化 JSON 值的类型。

参数

json
ReadOnlySpan<Char>

要分析的 JSON 文本。

options
JsonSerializerOptions

分析期间用于控制行为的选项。

返回

TValue

JSON 值的 TValue 表示。

例外

JSON 无效。

- 或 -

TValue 与 JSON 不兼容。

- 或 -

单个 JSON 值以外的跨度中存在剩余数据。

TValue 或其可序列化成员没有兼容的 JsonConverter

注解

使用 UTF-16 范围不如使用 UTF-8 方法高效,因为实现本机使用 UTF-8。

适用于

Deserialize<TValue>(String, JsonSerializerOptions)

Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs

将表示单个 JSON 值的文本分析为泛型类型参数指定的类型的实例。

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

类型参数

TValue

JSON 值的目标类型。

参数

json
String

要分析的 JSON 文本。

options
JsonSerializerOptions

分析期间用于控制行为的选项。

返回

TValue

JSON 值的 TValue 表示。

例外

jsonnull

JSON 无效。

- 或 -

TValue 与 JSON 不兼容。

- 或 -

单个 JSON 值以外的字符串中存在剩余数据。

TValue 或其可序列化成员没有兼容的 JsonConverter

注解

String使用 不如使用 UTF-8 方法高效,因为实现本机使用 UTF-8。

有关详细信息,请参阅 如何序列化和反序列化 JSON

适用于

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

Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs

将表示单个 JSON 值的文本分析为 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

类型参数

TValue

要反序列化 JSON 值的类型。

参数

json
ReadOnlySpan<Char>

要分析的 JSON 文本。

jsonTypeInfo
JsonTypeInfo<TValue>

有关要转换的类型的元数据。

返回

TValue

JSON 值的 TValue 表示。

例外

jsonnull

jsonTypeInfonull

JSON 无效。

- 或 -

TValue 与 JSON 不兼容。

- 或 -

单个 JSON 值以外的字符串中存在剩余数据。

TValue 或其可序列化成员没有兼容的 JsonConverter

注解

String使用 不如使用 UTF-8 方法高效,因为实现本机使用 UTF-8。

适用于

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

Source:
JsonSerializer.Read.Span.cs
Source:
JsonSerializer.Read.Span.cs
Source:
JsonSerializer.Read.Span.cs

将表示单个 JSON 值的 UTF-8 编码文本分析为 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

类型参数

TValue

要反序列化 JSON 值的类型。

参数

utf8Json
ReadOnlySpan<Byte>

要分析的 JSON 文本。

jsonTypeInfo
JsonTypeInfo<TValue>

有关要转换的类型的元数据。

返回

TValue

JSON 值的 TValue 表示。

例外

JSON 无效、 TValue 与 JSON 不兼容,或者流中存在剩余数据。

TValue 或其可序列化成员没有兼容的 JsonConverter

适用于

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

Source:
JsonSerializer.Read.Span.cs
Source:
JsonSerializer.Read.Span.cs
Source:
JsonSerializer.Read.Span.cs

将表示单个 JSON 值的 UTF-8 编码文本分析为泛型类型参数指定的类型的实例。

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

类型参数

TValue

UTF-8 编码文本的目标类型。

参数

utf8Json
ReadOnlySpan<Byte>

要分析的 JSON 文本。

options
JsonSerializerOptions

分析期间用于控制行为的选项。

返回

TValue

JSON 值的 TValue 表示。

例外

JSON 无效。

- 或 -

TValue 与 JSON 不兼容。

- 或 -

单个 JSON 值以外的跨度中存在剩余数据。

TValue 或其可序列化成员没有兼容的 JsonConverter

注解

有关详细信息,请参阅 如何序列化和反序列化 JSON

适用于

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

Source:
JsonSerializer.Read.Stream.cs
Source:
JsonSerializer.Read.Stream.cs
Source:
JsonSerializer.Read.Stream.cs

将表示单个 JSON 值的 UTF-8 编码文本读入 TValue。 流将读取到完成。

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

类型参数

TValue

要反序列化 JSON 值的类型。

参数

utf8Json
Stream

要分析的 JSON 数据。

jsonTypeInfo
JsonTypeInfo<TValue>

有关要转换的类型的元数据。

返回

TValue

JSON 值的 TValue 表示。

例外

utf8JsonjsonTypeInfonull

JSON 无效、 TValue 与 JSON 不兼容,或者流中存在剩余数据。

TValue 或其可序列化成员没有兼容的 JsonConverter

适用于

Deserialize<TValue>(Stream, JsonSerializerOptions)

Source:
JsonSerializer.Read.Stream.cs
Source:
JsonSerializer.Read.Stream.cs
Source:
JsonSerializer.Read.Stream.cs

将表示单个 JSON 值的 UTF-8 编码文本读入 TValue。 流将读取到完成。

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

类型参数

TValue

要反序列化 JSON 值的类型。

参数

utf8Json
Stream

要分析的 JSON 数据。

options
JsonSerializerOptions

读取期间用于控制行为的选项。

返回

TValue

JSON 值的 TValue 表示。

例外

utf8Jsonnull

JSON 无效、 TValue 与 JSON 不兼容,或者流中存在剩余数据。

TValue 或其可序列化成员没有兼容的 JsonConverter

适用于

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

Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs
Source:
JsonSerializer.Read.String.cs

将表示单个 JSON 值的文本分析为 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

类型参数

TValue

要反序列化 JSON 值的类型。

参数

json
String

要分析的 JSON 文本。

jsonTypeInfo
JsonTypeInfo<TValue>

有关要转换的类型的元数据。

返回

TValue

JSON 值的 TValue 表示。

例外

jsonnull

jsonTypeInfonull

JSON 无效。

- 或 -

TValue 与 JSON 不兼容。

- 或 -

单个 JSON 值以外的字符串中存在剩余数据。

TValue 或其可序列化成员没有兼容的 JsonConverter

注解

String使用 不如使用 UTF-8 方法高效,因为实现本机使用 UTF-8。

适用于