<PackageReference Include="System.Text.Json" Version="4.6.0" />

JsonDocument

public sealed class JsonDocument : IDisposable
Provides a mechanism for examining the structural content of a JSON value without automatically instantiating data values.
public JsonElement RootElement { get; }

Gets the root element of this JSON document.

public static JsonDocument Parse(ReadOnlyMemory<byte> utf8Json, JsonDocumentOptions options = default)

Parses memory as UTF-8-encoded text representing a single JSON byte value into a JsonDocument.

public static JsonDocument Parse(ReadOnlySequence<byte> utf8Json, JsonDocumentOptions options = default)

Parses a sequence as UTF-8-encoded text representing a single JSON byte value into a JsonDocument.

public static JsonDocument Parse(Stream utf8Json, JsonDocumentOptions options = default)

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

public static JsonDocument Parse(ReadOnlyMemory<char> json, JsonDocumentOptions options = default)

Parses text representing a single JSON character value into a JsonDocument.

public static JsonDocument Parse(string json, JsonDocumentOptions options = default)

Parses text representing a single JSON string value into a JsonDocument.

public static Task<JsonDocument> ParseAsync(Stream utf8Json, JsonDocumentOptions options = default, CancellationToken cancellationToken = default)

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

public static JsonDocument ParseValue(ref Utf8JsonReader reader)

Parses one JSON value (including objects or arrays) from the provided reader.

public static bool TryParseValue(ref Utf8JsonReader reader, out JsonDocument document)

Attempts to parse one JSON value (including objects or arrays) from the provided reader.

public void Dispose()

Releases the resources used by this JsonDocument instance.

public void WriteTo(Utf8JsonWriter writer)

Writes the document to the provided writer as a JSON value.