Editar

Compartilhar via


Utf8JsonReader.ValueSequence Property

Definition

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:
 property System::Buffers::ReadOnlySequence<System::Byte> ValueSequence { System::Buffers::ReadOnlySequence<System::Byte> get(); };
public System.Buffers.ReadOnlySequence<byte> ValueSequence { get; }
member this.ValueSequence : System.Buffers.ReadOnlySequence<byte>
Public ReadOnly Property ValueSequence As ReadOnlySequence(Of Byte)

Property Value

A byte read-only sequence.

Remarks

If the JSON is provided within a ReadOnlySequence<byte> and the slice that represents the token value fits in a single segment, then ValueSpan contains the sliced value since it can be represented as a span. Otherwise, ValueSequence contains the token value.

If HasValueSequence is false, ValueSequence is empty. Therefore, only access ValueSequence if HasValueSequence is true. Otherwise, the token value must be accessed from ValueSpan.

There is no guarantee that this property will always contain well-formed data. If the input JSON passed in to the Utf8JsonReader contains invalid UTF-8 bytes within JSON string tokens, this property will return back those invalid UTF-8 bytes as is. Therefore, if the input is untrusted or not previously validated, call GetString() to get the JSON string token.

Since this property returns the raw bytes, avoid using it for text comparison. Instead call ValueTextEquals, which unescapes the text if necessary.

Applies to