JsonDocument.ParseAsync(Stream, JsonDocumentOptions, CancellationToken) 方法

定义

将表示单个 JSON 值的 UTF-8 编码数据形式的 Stream 分析为 JsonDocument。Parses a Stream as UTF-8-encoded data representing a single JSON value into a JsonDocument. 数据流将被完整读取。The stream is read to completion.

public static System.Threading.Tasks.Task<System.Text.Json.JsonDocument> ParseAsync (System.IO.Stream utf8Json, System.Text.Json.JsonDocumentOptions options = default, System.Threading.CancellationToken cancellationToken = default);
static member ParseAsync : System.IO.Stream * System.Text.Json.JsonDocumentOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Text.Json.JsonDocument>
Public Shared Function ParseAsync (utf8Json As Stream, Optional options As JsonDocumentOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of JsonDocument)

参数

utf8Json
Stream

要分析的 JSON 数据。The JSON data to parse.

options
JsonDocumentOptions

分析期间用于控制读取器行为的选项。Options to control the reader behavior during parsing.

cancellationToken
CancellationToken

要监视取消请求的标记。The token to monitor for cancellation requests.

返回

Task<JsonDocument>

用于生成 JSON 值的 JsonDocument 表示的任务。A task to produce a JsonDocument representation of the JSON value.

例外

utf8Json 不表示有效的单个 JSON 值。utf8Json does not represent a valid single JSON value.

options 包含不受支持的选项。options contains unsupported options.

适用于