Επεξεργασία

Κοινή χρήση μέσω


JsonDocument.ParseAsync Method

Definition

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)

Parameters

utf8Json
Stream

The JSON data to parse.

options
JsonDocumentOptions

Options to control the reader behavior during parsing.

cancellationToken
CancellationToken

The token to monitor for cancellation requests.

Returns

A task to produce a JsonDocument representation of the JSON value.

Exceptions

utf8Json does not represent a valid single JSON value.

options contains unsupported options.

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

Remarks

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Parse(Stream, JsonDocumentOptions).

Applies to