JsonSerializer.DeserializeAsyncEnumerable 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
DeserializeAsyncEnumerable<TValue>(PipeReader, JsonTypeInfo<TValue>, Boolean, CancellationToken)
將 UTF-8 編碼的文字包裝成 IAsyncEnumerable<T> 可用於串流式反序列化 JSON 值序列的
public static System.Collections.Generic.IAsyncEnumerable<TValue?> DeserializeAsyncEnumerable<TValue>(System.IO.Pipelines.PipeReader utf8Json, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo, bool topLevelValues, System.Threading.CancellationToken cancellationToken = default);
static member DeserializeAsyncEnumerable : System.IO.Pipelines.PipeReader * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> * bool * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<'Value>
Public Function DeserializeAsyncEnumerable(Of TValue) (utf8Json As PipeReader, jsonTypeInfo As JsonTypeInfo(Of TValue), topLevelValues As Boolean, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of TValue)
類型參數
- TValue
非同步反序列化的元素類型。
參數
- utf8Json
- PipeReader
JSON 資料要解析。
- jsonTypeInfo
- JsonTypeInfo<TValue>
關於要轉換的元素類型的元資料。
- topLevelValues
- Boolean
是否要從頂層 JSON 值序列反序列化。
- cancellationToken
- CancellationToken
CancellationToken可以用 that 來取消讀取操作。
傳回
這是 IAsyncEnumerable<T> 所提供 JSON 序列的表示。
例外狀況
utf8Json 或 jsonTypeInfo 為 null。
備註
當 topLevelValues 設定為 true時,PipeReader 將 PipeReader 視為一串空白分隔的頂層 JSON 值,並嘗試將每個值反序列化為 TValue。
當 topLevelValues 設為 false時,PipeReader 將 PipeReader 視為 JSON 陣列,嘗試將每個元素序列化為 TValue。
適用於
DeserializeAsyncEnumerable<TValue>(Stream, JsonTypeInfo<TValue>, Boolean, CancellationToken)
將 UTF-8 編碼的文字包裝成 IAsyncEnumerable<T> 可用於串流式反序列化 JSON 值序列的
public static System.Collections.Generic.IAsyncEnumerable<TValue?> DeserializeAsyncEnumerable<TValue>(System.IO.Stream utf8Json, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo, bool topLevelValues, System.Threading.CancellationToken cancellationToken = default);
static member DeserializeAsyncEnumerable : System.IO.Stream * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> * bool * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<'Value>
Public Function DeserializeAsyncEnumerable(Of TValue) (utf8Json As Stream, jsonTypeInfo As JsonTypeInfo(Of TValue), topLevelValues As Boolean, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of TValue)
類型參數
- TValue
非同步反序列化的元素類型。
參數
- utf8Json
- Stream
JSON 資料要解析。
- jsonTypeInfo
- JsonTypeInfo<TValue>
關於要轉換的元素類型的元資料。
- topLevelValues
- Boolean
是否要從頂層 JSON 值序列反序列化。
- cancellationToken
- CancellationToken
CancellationToken可以用 that 來取消讀取操作。
傳回
這是 IAsyncEnumerable<T> 所提供 JSON 序列的表示。
例外狀況
utf8Json 或 jsonTypeInfo 為 null。
備註
當 topLevelValues 設為 true時,會將串流視為一串空白分隔的頂層 JSON 值,並嘗試將每個值反序列化成 TValue。
當 topLevelValues 設為 false時,會將串流視為 JSON 陣列,並嘗試將每個元素序列化成 TValue。
適用於
DeserializeAsyncEnumerable<TValue>(Stream, Boolean, JsonSerializerOptions, CancellationToken)
將 UTF-8 編碼的文字包裝成 IAsyncEnumerable<T> 可用於串流式反序列化 JSON 值序列的
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
public static System.Collections.Generic.IAsyncEnumerable<TValue?> DeserializeAsyncEnumerable<TValue>(System.IO.Stream utf8Json, bool topLevelValues, System.Text.Json.JsonSerializerOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
public static System.Collections.Generic.IAsyncEnumerable<TValue?> DeserializeAsyncEnumerable<TValue>(System.IO.Stream utf8Json, bool topLevelValues, System.Text.Json.JsonSerializerOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
static member DeserializeAsyncEnumerable : System.IO.Stream * bool * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<'Value>
static member DeserializeAsyncEnumerable : System.IO.Stream * bool * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<'Value>
Public Function DeserializeAsyncEnumerable(Of TValue) (utf8Json As Stream, topLevelValues As Boolean, Optional options As JsonSerializerOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of TValue)
類型參數
- TValue
非同步反序列化的元素類型。
參數
- utf8Json
- Stream
JSON 資料要解析。
- topLevelValues
- Boolean
true 從頂層 JSON 值序列反序列化,或 false 從單一頂層陣列反序列化。
- options
- JsonSerializerOptions
閱讀時可控制行為的選項。
- cancellationToken
- CancellationToken
CancellationToken可以用 that 來取消讀取操作。
傳回
這是 IAsyncEnumerable<T> 所提供 JSON 序列的表示。
- 屬性
例外狀況
utf8Json 是 null。
備註
當 topLevelValues 設為 true時,會將串流視為一串空白分隔的頂層 JSON 值,並嘗試將每個值反序列化成 TValue。
當 topLevelValues 設為 false時,會將串流視為 JSON 陣列,並嘗試將每個元素序列化成 TValue。
適用於
DeserializeAsyncEnumerable<TValue>(PipeReader, Boolean, JsonSerializerOptions, CancellationToken)
將 UTF-8 編碼的文字包裝成 IAsyncEnumerable<T> 可用於串流式反序列化 JSON 值序列的
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
public static System.Collections.Generic.IAsyncEnumerable<TValue?> DeserializeAsyncEnumerable<TValue>(System.IO.Pipelines.PipeReader utf8Json, bool topLevelValues, System.Text.Json.JsonSerializerOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
public static System.Collections.Generic.IAsyncEnumerable<TValue?> DeserializeAsyncEnumerable<TValue>(System.IO.Pipelines.PipeReader utf8Json, bool topLevelValues, System.Text.Json.JsonSerializerOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
static member DeserializeAsyncEnumerable : System.IO.Pipelines.PipeReader * bool * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<'Value>
static member DeserializeAsyncEnumerable : System.IO.Pipelines.PipeReader * bool * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<'Value>
Public Function DeserializeAsyncEnumerable(Of TValue) (utf8Json As PipeReader, topLevelValues As Boolean, Optional options As JsonSerializerOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of TValue)
類型參數
- TValue
非同步反序列化的元素類型。
參數
- utf8Json
- PipeReader
JSON 資料要解析。
- topLevelValues
- Boolean
true 從頂層 JSON 值序列反序列化,或 false 從單一頂層陣列反序列化。
- options
- JsonSerializerOptions
閱讀時可控制行為的選項。
- cancellationToken
- CancellationToken
CancellationToken可以用 that 來取消讀取操作。
傳回
這是 IAsyncEnumerable<T> 所提供 JSON 序列的表示。
- 屬性
例外狀況
utf8Json 是 null。
備註
當 topLevelValues 設定為 true時,PipeReader 將 PipeReader 視為一串空白分隔的頂層 JSON 值,並嘗試將每個值反序列化為 TValue。
當 topLevelValues 設為 false時,PipeReader 將 PipeReader 視為 JSON 陣列,嘗試將每個元素序列化為 TValue。
適用於
DeserializeAsyncEnumerable<TValue>(Stream, JsonTypeInfo<TValue>, CancellationToken)
將 UTF-8 編碼的文字包裝成可用於串流式反序列化根層 JSON 陣列的 格式 IAsyncEnumerable<T> 。
public static System.Collections.Generic.IAsyncEnumerable<TValue?> DeserializeAsyncEnumerable<TValue>(System.IO.Stream utf8Json, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo, System.Threading.CancellationToken cancellationToken = default);
static member DeserializeAsyncEnumerable : System.IO.Stream * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<'Value>
Public Function DeserializeAsyncEnumerable(Of TValue) (utf8Json As Stream, jsonTypeInfo As JsonTypeInfo(Of TValue), Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of TValue)
類型參數
- TValue
非同步反序列化的元素類型。
參數
- utf8Json
- Stream
JSON 資料要解析。
- jsonTypeInfo
- JsonTypeInfo<TValue>
關於要轉換的元素類型的元資料。
- cancellationToken
- CancellationToken
CancellationToken可以用 that 來取消讀取操作。
傳回
這是 IAsyncEnumerable<T> 所提供 JSON 陣列的表示法。
例外狀況
utf8Json 或 jsonTypeInfo 為 null。
取消令牌也被取消了。 此例外會儲存在回傳的任務中。
適用於
DeserializeAsyncEnumerable<TValue>(Stream, JsonSerializerOptions, CancellationToken)
將 UTF-8 編碼的文字包裝成可用於串流式反序列化根層 JSON 陣列的 格式 IAsyncEnumerable<T> 。
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
public static System.Collections.Generic.IAsyncEnumerable<TValue?> DeserializeAsyncEnumerable<TValue>(System.IO.Stream utf8Json, System.Text.Json.JsonSerializerOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
public static System.Collections.Generic.IAsyncEnumerable<TValue?> DeserializeAsyncEnumerable<TValue>(System.IO.Stream utf8Json, System.Text.Json.JsonSerializerOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
public static System.Collections.Generic.IAsyncEnumerable<TValue?> DeserializeAsyncEnumerable<TValue>(System.IO.Stream utf8Json, System.Text.Json.JsonSerializerOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
static member DeserializeAsyncEnumerable : System.IO.Stream * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<'Value>
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
static member DeserializeAsyncEnumerable : System.IO.Stream * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<'Value>
static member DeserializeAsyncEnumerable : System.IO.Stream * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<'Value>
Public Function DeserializeAsyncEnumerable(Of TValue) (utf8Json As Stream, Optional options As JsonSerializerOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of TValue)
類型參數
- TValue
非同步反序列化的元素類型。
參數
- utf8Json
- Stream
JSON 資料要解析。
- options
- JsonSerializerOptions
閱讀時可控制行為的選項。
- cancellationToken
- CancellationToken
CancellationToken可以用 that 來取消讀取操作。
傳回
這是 IAsyncEnumerable<T> 所提供 JSON 陣列的表示法。
- 屬性
例外狀況
utf8Json 是 null。
取消令牌也被取消了。 此例外會儲存在回傳的任務中。
適用於
DeserializeAsyncEnumerable<TValue>(PipeReader, JsonTypeInfo<TValue>, CancellationToken)
將 UTF-8 編碼的文字包裝成可用於串流式反序列化根層 JSON 陣列的 格式 IAsyncEnumerable<T> 。
public static System.Collections.Generic.IAsyncEnumerable<TValue?> DeserializeAsyncEnumerable<TValue>(System.IO.Pipelines.PipeReader utf8Json, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo, System.Threading.CancellationToken cancellationToken = default);
static member DeserializeAsyncEnumerable : System.IO.Pipelines.PipeReader * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<'Value>
Public Function DeserializeAsyncEnumerable(Of TValue) (utf8Json As PipeReader, jsonTypeInfo As JsonTypeInfo(Of TValue), Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of TValue)
類型參數
- TValue
非同步反序列化的元素類型。
參數
- utf8Json
- PipeReader
JSON 資料要解析。
- jsonTypeInfo
- JsonTypeInfo<TValue>
關於要轉換的元素類型的元資料。
- cancellationToken
- CancellationToken
CancellationToken可以用 that 來取消讀取操作。
傳回
這是 IAsyncEnumerable<T> 所提供 JSON 陣列的表示法。
例外狀況
utf8Json 或 jsonTypeInfo 為 null。
適用於
DeserializeAsyncEnumerable<TValue>(PipeReader, JsonSerializerOptions, CancellationToken)
將 UTF-8 編碼的文字包裝成可用於串流式反序列化根層 JSON 陣列的 格式 IAsyncEnumerable<T> 。
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
public static System.Collections.Generic.IAsyncEnumerable<TValue?> DeserializeAsyncEnumerable<TValue>(System.IO.Pipelines.PipeReader utf8Json, System.Text.Json.JsonSerializerOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
public static System.Collections.Generic.IAsyncEnumerable<TValue?> DeserializeAsyncEnumerable<TValue>(System.IO.Pipelines.PipeReader utf8Json, System.Text.Json.JsonSerializerOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
static member DeserializeAsyncEnumerable : System.IO.Pipelines.PipeReader * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<'Value>
static member DeserializeAsyncEnumerable : System.IO.Pipelines.PipeReader * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<'Value>
Public Function DeserializeAsyncEnumerable(Of TValue) (utf8Json As PipeReader, Optional options As JsonSerializerOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of TValue)
類型參數
- TValue
非同步反序列化的元素類型。
參數
- utf8Json
- PipeReader
JSON 資料要解析。
- options
- JsonSerializerOptions
閱讀時可控制行為的選項。
- cancellationToken
- CancellationToken
CancellationToken可以用 that 來取消讀取操作。
傳回
這是 IAsyncEnumerable<T> 所提供 JSON 陣列的表示法。
- 屬性
例外狀況
utf8Json 是 null。