<PackageReference Include="System.Text.Json" Version="8.0.0-preview.5.23280.8" />

Utf8JsonReader

public struct Utf8JsonReader
Provides a high-performance API for forward-only, read-only access to UTF-8 encoded JSON text.
public long BytesConsumed { get; }

Gets the total number of bytes consumed so far by this instance of the Utf8JsonReader.

public int CurrentDepth { get; }

Gets the depth of the current token.

public JsonReaderState CurrentState { get; }

Gets the current Utf8JsonReader state to pass to a Utf8JsonReader constructor with more data.

public bool HasValueSequence { get; }

Gets a value that indicates which Value property to use to get the token value.

public bool IsFinalBlock { get; }

Gets the mode of this instance of the Utf8JsonReader which indicates whether all the JSON data was provided or there is more data to come.

public SequencePosition Position { get; }

Gets the current SequencePosition within the provided UTF-8 encoded input ReadOnlySequence<byte> or a default SequencePosition if the Utf8JsonReader struct was constructed with a ReadOnlySpan<byte>.

public long TokenStartIndex { get; }

Gets the index that the last processed JSON token starts at (within the given UTF-8 encoded input text), skipping any white space.

public JsonTokenType TokenType { get; }

Gets the type of the last processed JSON token in the UTF-8 encoded JSON text.

public bool ValueIsEscaped { get; }

Gets a value that indicates whether the current ValueSpan or ValueSequence properties contain escape sequences per RFC 8259 section 7, and therefore require unescaping before being consumed.

public ReadOnlySequence<byte> ValueSequence { get; }

Gets the raw value of the last processed token as a ReadOnlySequence<byte> slice of the input payload, only if the token is contained within multiple segments.

public ReadOnlySpan<byte> ValueSpan { get; }

Gets the raw value of the last processed token as a ReadOnlySpan<byte> slice of the input payload, if the token fits in a single segment or if the reader was constructed with a JSON payload contained in a ReadOnlySpan<byte>.

public Utf8JsonReader(ReadOnlySpan<byte> jsonData, bool isFinalBlock, JsonReaderState state)

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.

public Utf8JsonReader(ReadOnlySpan<byte> jsonData, JsonReaderOptions options = default)

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

public Utf8JsonReader(ReadOnlySequence<byte> jsonData, bool isFinalBlock, JsonReaderState state)

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.

public Utf8JsonReader(ReadOnlySequence<byte> jsonData, JsonReaderOptions options = default)

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

public int CopyString(Span<byte> utf8Destination)

Copies the current JSON token value from the source, unescaped as a UTF-8 string to the destination buffer.

public int CopyString(Span<char> destination)

Copies the current JSON token value from the source, unescaped, and transcoded as a UTF-16 char buffer.

public bool GetBoolean()

Reads the next JSON token value from the source as a Boolean.

public byte GetByte()

Parses the current JSON token value from the source as a Byte.

public byte[] GetBytesFromBase64()

Parses the current JSON token value from the source and decodes the Base64 encoded JSON string as a byte array.

public string GetComment()

Parses the current JSON token value from the source as a comment, transcoded it as a String.

Reads the next JSON token value from the source and parses it to a DateTime.

Reads the next JSON token value from the source and parses it to a DateTimeOffset.

public decimal GetDecimal()

Reads the next JSON token value from the source and parses it to a Decimal.

public double GetDouble()

Reads the next JSON token value from the source and parses it to a Double.

public Guid GetGuid()

Reads the next JSON token value from the source and parses it to a Guid.

public short GetInt16()

Parses the current JSON token value from the source as a Int16.

public int GetInt32()

Reads the next JSON token value from the source and parses it to an Int32.

public long GetInt64()

Reads the next JSON token value from the source and parses it to an Int64.

public sbyte GetSByte()

Parses the current JSON token value from the source as an SByte.

public float GetSingle()

Reads the next JSON token value from the source and parses it to a Single.

public string GetString()

Reads the next JSON token value from the source, unescaped, and transcoded as a string.

public ushort GetUInt16()

Parses the current JSON token value from the source as a UInt16.

public uint GetUInt32()

Reads the next JSON token value from the source and parses it to a UInt32.

public ulong GetUInt64()

Reads the next JSON token value from the source and parses it to a UInt64.

public bool Read()

Reads the next JSON token from the input source.

public void Skip()

Skips the children of the current JSON token.

public bool TryGetByte(out byte value)

Tries to parse the current JSON token value from the source as a Byte and returns a value that indicates whether the operation succeeded.

public bool TryGetBytesFromBase64(out byte value)

Tries to parse the current JSON token value from the source and decodes the Base64 encoded JSON string as a byte array and returns a value that indicates whether the operation succeeded.

public bool TryGetDateTime(out DateTime value)

Tries to parse the current JSON token value from the source as a DateTime and returns a value that indicates whether the operation succeeded.

public bool TryGetDateTimeOffset(out DateTimeOffset value)

Tries to parse the current JSON token value from the source as a DateTimeOffset and returns a value that indicates whether the operation succeeded.

public bool TryGetDecimal(out decimal value)

Tries to parse the current JSON token value from the source as a Decimal and returns a value that indicates whether the operation succeeded.

public bool TryGetDouble(out double value)

Tries to parse the current JSON token value from the source as a Double and returns a value that indicates whether the operation succeeded.

public bool TryGetGuid(out Guid value)

Tries to parse the current JSON token value from the source as a Guid and returns a value that indicates whether the operation succeeded.

public bool TryGetInt16(out short value)

Tries to parse the current JSON token value from the source as an Int16 and returns a value that indicates whether the operation succeeded.

public bool TryGetInt32(out int value)

Tries to parse the current JSON token value from the source as an Int32 and returns a value that indicates whether the operation succeeded.

public bool TryGetInt64(out long value)

Tries to parse the current JSON token value from the source as an Int64 and returns a value that indicates whether the operation succeeded.

public bool TryGetSByte(out sbyte value)

Tries to parse the current JSON token value from the source as an SByte and returns a value that indicates whether the operation succeeded.

public bool TryGetSingle(out float value)

Tries to parse the current JSON token value from the source as a Single and returns a value that indicates whether the operation succeeded.

public bool TryGetUInt16(out ushort value)

Tries to parse the current JSON token value from the source as a UInt16 and returns a value that indicates whether the operation succeeded.

public bool TryGetUInt32(out uint value)

Tries to parse the current JSON token value from the source as a UInt32 and returns a value that indicates whether the operation succeeded.

public bool TryGetUInt64(out ulong value)

Tries to parse the current JSON token value from the source as a UInt64 and returns a value that indicates whether the operation succeeded.

public bool TrySkip()

Tries to skip the children of the current JSON token.

public bool ValueTextEquals(ReadOnlySpan<byte> utf8Text)

Compares the UTF-8 encoded text in a read-only byte span to the unescaped JSON token value in the source and returns a value that indicates whether they match.

public bool ValueTextEquals(string text)

Compares the string text to the unescaped JSON token value in the source and returns a value that indicates whether they match.

public bool ValueTextEquals(ReadOnlySpan<char> text)

Compares the text in a read-only character span to the unescaped JSON token value in the source and returns a value that indicates whether they match.