Utf8JsonReader Constructors

Definition

Overloads

Utf8JsonReader(ReadOnlySequence<Byte>, JsonReaderOptions)

Initializes a new instance of the Utf8JsonReader structure that processes a read-only sequence of UTF-8 encoded text using the specified options.

Utf8JsonReader(ReadOnlySpan<Byte>, JsonReaderOptions)

Initializes a new instance of the Utf8JsonReader structure that processes a read-only span of UTF-8 encoded text using the specified options.

Utf8JsonReader(ReadOnlySequence<Byte>, Boolean, JsonReaderState)

Initializes a new instance of the Utf8JsonReader structure that processes a read-only sequence of UTF-8 encoded text and indicates whether the input contains all the text to process.

Utf8JsonReader(ReadOnlySpan<Byte>, Boolean, JsonReaderState)

Initializes a new instance of the Utf8JsonReader structure that processes a read-only span of UTF-8 encoded text and indicates whether the input contains all the text to process.

Utf8JsonReader(ReadOnlySequence<Byte>, JsonReaderOptions)

Source:
Utf8JsonReader.MultiSegment.cs
Source:
Utf8JsonReader.MultiSegment.cs
Source:
Utf8JsonReader.MultiSegment.cs
Source:
Utf8JsonReader.MultiSegment.cs
Source:
Utf8JsonReader.MultiSegment.cs
Source:
Utf8JsonReader.MultiSegment.cs

Initializes a new instance of the Utf8JsonReader structure that processes a read-only sequence of UTF-8 encoded text using the specified options.

C#
public Utf8JsonReader(System.Buffers.ReadOnlySequence<byte> jsonData, System.Text.Json.JsonReaderOptions options = default);

Parameters

jsonData
ReadOnlySequence<Byte>

The UTF-8 encoded JSON text to process.

options
JsonReaderOptions

Options that define customized behavior of the Utf8JsonReader that differs from the JSON RFC (for example, how to handle comments or maximum depth allowed when reading). By default, the Utf8JsonReader follows the JSON RFC strictly; comments within the JSON are invalid, and the maximum depth is 64.

Remarks

Since this type is a ref struct, it is a stack-only type, and all the limitations of ref structs apply to it.

This constructor assumes that the entire JSON payload is contained in jsonData; it is equivalent to Utf8JsonReader.IsFinalBlock = true.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

Utf8JsonReader(ReadOnlySpan<Byte>, JsonReaderOptions)

Source:
Utf8JsonReader.cs
Source:
Utf8JsonReader.cs
Source:
Utf8JsonReader.cs
Source:
Utf8JsonReader.cs
Source:
Utf8JsonReader.cs
Source:
Utf8JsonReader.cs

Initializes a new instance of the Utf8JsonReader structure that processes a read-only span of UTF-8 encoded text using the specified options.

C#
public Utf8JsonReader(ReadOnlySpan<byte> jsonData, System.Text.Json.JsonReaderOptions options = default);

Parameters

jsonData
ReadOnlySpan<Byte>

The UTF-8 encoded JSON text to process.

options
JsonReaderOptions

Options that define customized behavior of the Utf8JsonReader that differs from the JSON RFC (for example, how to handle comments or maximum depth allowed when reading). By default, the Utf8JsonReader follows the JSON RFC strictly; comments within the JSON are invalid, and the maximum depth is 64.

Remarks

Since this type is a ref struct, it is a stack-only type, and all the limitations of ref structs apply to it.

This constructor assumes that the entire JSON payload is contained in jsonData; it is equivalent to Utf8JsonReader.IsFinalBlock = true.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

Utf8JsonReader(ReadOnlySequence<Byte>, Boolean, JsonReaderState)

Source:
Utf8JsonReader.MultiSegment.cs
Source:
Utf8JsonReader.MultiSegment.cs
Source:
Utf8JsonReader.MultiSegment.cs
Source:
Utf8JsonReader.MultiSegment.cs
Source:
Utf8JsonReader.MultiSegment.cs
Source:
Utf8JsonReader.MultiSegment.cs

Initializes a new instance of the Utf8JsonReader structure that processes a read-only sequence of UTF-8 encoded text and indicates whether the input contains all the text to process.

C#
public Utf8JsonReader(System.Buffers.ReadOnlySequence<byte> jsonData, bool isFinalBlock, System.Text.Json.JsonReaderState state);

Parameters

jsonData
ReadOnlySequence<Byte>

The UTF-8 encoded JSON text to process.

isFinalBlock
Boolean

true to indicate that the input sequence contains the entire data to process; false to indicate that the input span contains partial data with more data to follow.

state
JsonReaderState

The reader state. If this is the first call to the constructor, pass the default state; otherwise, pass the value of the CurrentState property from the previous instance of the Utf8JsonReader.

Remarks

Since this type is a ref struct, it is a stack-only type, and all the limitations of ref structs apply to it. This is the reason why the constructor accepts a JsonReaderState.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

Utf8JsonReader(ReadOnlySpan<Byte>, Boolean, JsonReaderState)

Source:
Utf8JsonReader.cs
Source:
Utf8JsonReader.cs
Source:
Utf8JsonReader.cs
Source:
Utf8JsonReader.cs
Source:
Utf8JsonReader.cs
Source:
Utf8JsonReader.cs

Initializes a new instance of the Utf8JsonReader structure that processes a read-only span of UTF-8 encoded text and indicates whether the input contains all the text to process.

C#
public Utf8JsonReader(ReadOnlySpan<byte> jsonData, bool isFinalBlock, System.Text.Json.JsonReaderState state);

Parameters

jsonData
ReadOnlySpan<Byte>

The UTF-8 encoded JSON text to process.

isFinalBlock
Boolean

true to indicate that the input sequence contains the entire data to process; false to indicate that the input span contains partial data with more data to follow.

state
JsonReaderState

The reader state. If this is the first call to the constructor, pass the default state; otherwise, pass the value of the CurrentState property from the previous instance of the Utf8JsonReader.

Remarks

Since this type is a ref struct, it is a stack-only type, and all the limitations of ref structs apply to it. This is the reason why the constructor accepts a JsonReaderState.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)