Прочетете на английски Редактиране

Споделяне чрез


JsonNode.ParseAsync Method

Definition

Parses a Stream as UTF-8 encoded data representing a single JSON value into a JsonNode. The stream will be read to completion.

C#
public static System.Threading.Tasks.Task<System.Text.Json.Nodes.JsonNode?> ParseAsync(System.IO.Stream utf8Json, System.Text.Json.Nodes.JsonNodeOptions? nodeOptions = default, System.Text.Json.JsonDocumentOptions documentOptions = default, System.Threading.CancellationToken cancellationToken = default);

Parameters

utf8Json
Stream

The JSON text to parse.

nodeOptions
Nullable<JsonNodeOptions>

Options to control the node behavior after parsing.

documentOptions
JsonDocumentOptions

Options to control the document behavior during parsing.

cancellationToken
CancellationToken

The token to monitor for cancellation requests.

Returns

A Task to produce either a JsonNode representation of the JSON value, or null if the input represents the null JSON value.

Exceptions

utf8Json does not represent a valid single JSON value.

The cancellation token was canceled. This exception is stored into the returned task.

Applies to

Продукт Версии
.NET 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)