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.

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

Product Versies
.NET 6 (package-provided), 7 (package-provided), 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)