JsonSerializer.Deserialize 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
Deserialize(Stream, JsonTypeInfo)
将表示单个 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
表示。
例外
utf8Json
或 jsonTypeInfo
为 null
。
JSON 无效,或者流中存在剩余数据。
适用于
Deserialize(Utf8JsonReader, Type, JsonSerializerContext)
读取一个 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
表示。
例外
returnType
或 context
为 null
。
Json 无效,returnType
与 JSON 不兼容,或者无法从读取器读取值。
reader
使用的是不受支持的选项。
returnType
或其可序列化成员没有兼容的 JsonConverter。
GetTypeInfo(Type)提供的 context
上的 方法未返回与 returnType
兼容的 JsonTypeInfo 。
注解
TokenType如果 的 reader
属性为 PropertyName 或 None,则读取器将通过对 的一次调用Read()来提前确定值的开头。
此方法完成后, reader
位于 JSON 值中的最终标记处。 如果引发异常,读取器将重置为调用 方法时处于的状态。
此方法创建读取器操作的数据的副本,因此除了此方法的返回之外,调用方不需要维护数据完整性。
JsonReaderOptions用于创建 实例的 Utf8JsonReader 在发生冲突时优先于 JsonSerializerOptions 。 因此,读取 AllowTrailingCommas时使用 、 MaxDepth和 CommentHandling 。
适用于
Deserialize(Utf8JsonReader, Type, JsonSerializerOptions)
读取一个 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
表示。
例外
returnType
为 null
。
reader
使用的是不受支持的选项。
returnType
或其可序列化成员没有兼容的 JsonConverter。
注解
TokenType如果 的 reader
属性为 JsonTokenType.PropertyName 或 JsonTokenType.None,则读取器将通过对 的一次调用Utf8JsonReader.Read()来提前确定值的开头。
完成此方法后, reader
将定位在 JSON 值中的最终标记处。 如果引发异常,读取器将重置为调用 方法时处于的状态。
此方法创建读取器操作的数据的副本,因此除了此方法的返回之外,调用方不需要维护数据完整性。
JsonReaderOptions用于创建 实例的 Utf8JsonReader 在发生冲突时优先于 JsonSerializerOptions 。 因此,读取 JsonReaderOptions.AllowTrailingCommas时使用 、 JsonReaderOptions.MaxDepth和 JsonReaderOptions.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
参数
- returnType
- Type
要转换为并返回的对象的类型。
- options
- JsonSerializerOptions
分析期间用于控制行为的选项。
返回
JSON 值的 returnType
表示。
例外
returnType
与 JSON 不兼容。
returnType
或其可序列化成员没有兼容的 JsonConverter。
适用于
Deserialize(JsonElement, Type, JsonSerializerContext)
将 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
表示。
例外
returnType
或其可序列化成员没有兼容的 JsonConverter。
GetTypeInfo(Type)提供的 context
的 方法返回null
要转换的类型。
适用于
Deserialize(JsonElement, Type, JsonSerializerOptions)
将 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
表示。
例外
returnType
为 null
。
returnType
与 JSON 不兼容。
returnType
或其可序列化成员没有兼容的 JsonConverter。
适用于
Deserialize(JsonDocument, Type, JsonSerializerContext)
将 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
表示。
例外
returnType
或其可序列化成员没有兼容的 JsonConverter。
GetTypeInfo(Type)提供的 context
的 方法返回null
要转换的类型。
适用于
Deserialize(JsonDocument, Type, JsonSerializerOptions)
将 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
表示。
例外
document
或 returnType
为 null
。
returnType
与 JSON 不兼容。
returnType
或其可序列化成员没有兼容的 JsonConverter。
适用于
Deserialize(String, Type, JsonSerializerContext)
将表示单个 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
表示。
例外
returnType
或其可序列化成员没有兼容的 JsonConverter。
GetTypeInfo(Type)提供的 context
的 方法返回null
要转换的类型。
注解
String使用 不如使用 UTF-8 方法高效,因为实现本机使用 UTF-8。
适用于
Deserialize(String, Type, JsonSerializerOptions)
将表示单个 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
表示。
例外
json
或 returnType
为 null
。
returnType
或其可序列化成员没有兼容的 JsonConverter。
注解
String使用 不如使用 UTF-8 方法高效,因为实现本机使用 UTF-8。
有关详细信息,请参阅 如何序列化和反序列化 JSON。
适用于
Deserialize(ReadOnlySpan<Char>, Type, JsonSerializerContext)
将表示单个 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
表示。
例外
returnType
或其可序列化成员没有兼容的 JsonConverter。
GetTypeInfo(Type)提供的 context
方法返回null
要转换的类型。
注解
String使用 不如使用 UTF-8 方法高效,因为实现本机使用 UTF-8。
适用于
Deserialize(ReadOnlySpan<Char>, Type, JsonSerializerOptions)
将表示单个 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
表示。
例外
returnType
为 null
。
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
参数
- returnType
- Type
要转换为并返回的对象的类型。
- context
- JsonSerializerContext
可序列化类型的元数据提供程序。
返回
JSON 值的 returnType
表示。
例外
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
表示。
例外
returnType
为 null
。
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
表示。
例外
returnType
为 null
。
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)
将表示单个 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
表示。
例外
注解
String使用 不如使用 UTF-8 方法高效,因为实现本机使用 UTF-8。
适用于
Deserialize(JsonDocument, JsonTypeInfo)
将 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
表示。
例外
适用于
Deserialize(ReadOnlySpan<Char>, JsonTypeInfo)
将表示单个 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
表示。
例外
jsonTypeInfo
为 null
。
注解
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
参数
- jsonTypeInfo
- JsonTypeInfo
有关要转换的类型的元数据。
返回
JSON 值的 jsonTypeInfo
表示。
例外
jsonTypeInfo
为 null
。
适用于
Deserialize(Utf8JsonReader, JsonTypeInfo)
将一个 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
属性为 PropertyName 或 None,则读取器将通过对 的一次调用Read()来提前确定值的开头。
完成此方法后, reader
将定位在 JSON 值中的最终标记处。 如果引发异常,读取器将重置为调用 方法时处于的状态。
此方法会复制读取者处理的数据,因此,除了此方法的返回之外,调用方不需要维护数据完整性。
JsonReaderOptions用于创建 实例的 Utf8JsonReader 在发生冲突时优先于 JsonSerializerOptions 。 因此, AllowTrailingCommas读取时会使用 、 MaxDepth和 CommentHandling 。
适用于
Deserialize(Stream, Type, JsonSerializerOptions)
将表示单个 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
表示。
例外
utf8Json
或 returnType
为 null
。
JSON 无效,与 returnType
JSON 不兼容,或者流中存在剩余数据。
returnType
或其可序列化成员没有兼容的 JsonConverter。
适用于
Deserialize(Stream, Type, JsonSerializerContext)
将表示单个 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
表示。
例外
utf8Json
、returnType
或 context
为 null
。
JSON 无效,与 returnType
JSON 不兼容,或者流中存在剩余数据。
returnType
或其可序列化成员没有兼容的 JsonConverter。
GetTypeInfo(Type)提供的 context
上的 方法未返回与 returnType
兼容的 JsonTypeInfo 。
适用于
Deserialize(JsonElement, JsonTypeInfo)
将 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
表示。
例外
jsonTypeInfo
为 null
。
适用于
Deserialize<TValue>(Utf8JsonReader, JsonTypeInfo<TValue>)
读取一个 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>
有关要转换的类型的元数据。
返回
JSON 值的 TValue
表示。
例外
Json 无效,TValue
与 JSON 不兼容,或者无法从读取器读取值。
reader
使用的是不受支持的选项。
TValue
或其可序列化成员没有兼容的 JsonConverter。
注解
TokenType如果 的 reader
属性为 PropertyName 或 None,则读取器将通过对 的一次调用Read()来提前确定值的开头。
完成此方法后, reader
位于 JSON 值中的最终标记处。 如果引发异常,读取器将重置为调用 方法时处于的状态。
此方法会复制读取者处理的数据,因此,除了此方法的返回之外,调用方不需要维护数据完整性。
JsonReaderOptions用于创建 实例的 Utf8JsonReader 在发生冲突时优先于 JsonSerializerOptions 。 因此, AllowTrailingCommas读取时会使用 、 MaxDepth和 CommentHandling 。
适用于
Deserialize<TValue>(JsonDocument, JsonTypeInfo<TValue>)
将 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>
有关要转换的类型的元数据。
返回
JSON 值的 TValue
表示。
例外
TValue
与 JSON 不兼容。
TValue
或其可序列化成员没有兼容的 JsonConverter。
适用于
Deserialize<TValue>(Utf8JsonReader, JsonSerializerOptions)
将一个 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
读取期间用于控制序列化程序行为的选项。
返回
JSON 值的 TValue
表示。
例外
reader
不受支持的选项。
TValue
或其可序列化成员没有兼容的 JsonConverter。
注解
TokenType如果 的 reader
属性为 JsonTokenType.PropertyName 或 JsonTokenType.None,则读取器将通过对 的一次调用Utf8JsonReader.Read()来提前确定值的开头。
完成此方法后, reader
将定位在 JSON 值中的最终标记处。 如果引发异常,读取器将重置为调用 方法时处于的状态。
此方法会复制读取者处理的数据,因此,除了此方法的返回之外,调用方不需要维护数据完整性。
JsonReaderOptions用于创建 实例的 Utf8JsonReader 在发生冲突时优先于 JsonSerializerOptions 。 因此, JsonReaderOptions.AllowTrailingCommas读取时会使用 、 JsonReaderOptions.MaxDepth和 JsonReaderOptions.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 值的类型。
参数
- jsonTypeInfo
- JsonTypeInfo<TValue>
有关要转换的类型的元数据。
返回
JSON 值的 TValue
表示。
例外
jsonTypeInfo
为 null
。
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 值的类型。
参数
- options
- JsonSerializerOptions
分析期间用于控制行为的选项。
返回
JSON 值的 TValue
表示。
例外
TValue
与 JSON 不兼容。
TValue
或其可序列化成员没有兼容的 JsonConverter。
适用于
Deserialize<TValue>(JsonElement, JsonTypeInfo<TValue>)
将 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>
有关要转换的类型的元数据。
返回
JSON 值的 TValue
表示。
例外
jsonTypeInfo
为 null
。
TValue
与 JSON 不兼容。
TValue
或其可序列化成员没有兼容的 JsonConverter。
适用于
Deserialize<TValue>(JsonElement, JsonSerializerOptions)
将 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
分析期间用于控制行为的选项。
返回
JSON 值的 TValue
表示。
例外
TValue
与 JSON 不兼容。
TValue
或其可序列化成员没有兼容的 JsonConverter。
适用于
Deserialize<TValue>(JsonDocument, JsonSerializerOptions)
将 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
分析期间用于控制行为的选项。
返回
JSON 值的 TValue
表示。
例外
document
为 null
。
TValue
与 JSON 不兼容。
TValue
或其可序列化成员没有兼容的 JsonConverter。
适用于
Deserialize<TValue>(ReadOnlySpan<Char>, JsonSerializerOptions)
将表示单个 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
分析期间用于控制行为的选项。
返回
JSON 值的 TValue
表示。
例外
TValue
或其可序列化成员没有兼容的 JsonConverter。
注解
使用 UTF-16 范围不如使用 UTF-8 方法高效,因为实现本机使用 UTF-8。
适用于
Deserialize<TValue>(String, JsonSerializerOptions)
将表示单个 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
分析期间用于控制行为的选项。
返回
JSON 值的 TValue
表示。
例外
json
为 null
。
TValue
或其可序列化成员没有兼容的 JsonConverter。
注解
String使用 不如使用 UTF-8 方法高效,因为实现本机使用 UTF-8。
有关详细信息,请参阅 如何序列化和反序列化 JSON。
适用于
Deserialize<TValue>(ReadOnlySpan<Char>, JsonTypeInfo<TValue>)
将表示单个 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>
有关要转换的类型的元数据。
返回
JSON 值的 TValue
表示。
例外
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>
有关要转换的类型的元数据。
返回
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
分析期间用于控制行为的选项。
返回
JSON 值的 TValue
表示。
例外
TValue
或其可序列化成员没有兼容的 JsonConverter。
注解
有关详细信息,请参阅 如何序列化和反序列化 JSON。
适用于
Deserialize<TValue>(Stream, JsonTypeInfo<TValue>)
将表示单个 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>
有关要转换的类型的元数据。
返回
JSON 值的 TValue
表示。
例外
utf8Json
或 jsonTypeInfo
为 null
。
JSON 无效、 TValue
与 JSON 不兼容,或者流中存在剩余数据。
TValue
或其可序列化成员没有兼容的 JsonConverter。
适用于
Deserialize<TValue>(Stream, JsonSerializerOptions)
将表示单个 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
读取期间用于控制行为的选项。
返回
JSON 值的 TValue
表示。
例外
utf8Json
为 null
。
JSON 无效、 TValue
与 JSON 不兼容,或者流中存在剩余数据。
TValue
或其可序列化成员没有兼容的 JsonConverter。
适用于
Deserialize<TValue>(String, JsonTypeInfo<TValue>)
将表示单个 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>
有关要转换的类型的元数据。
返回
JSON 值的 TValue
表示。
例外
TValue
或其可序列化成员没有兼容的 JsonConverter。
注解
String使用 不如使用 UTF-8 方法高效,因为实现本机使用 UTF-8。
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈