Utf8JsonReader.ValueTextEquals Method

Definition

Overloads

ValueTextEquals(ReadOnlySpan<Byte>)

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.

ValueTextEquals(ReadOnlySpan<Char>)

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.

ValueTextEquals(String)

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

ValueTextEquals(ReadOnlySpan<Byte>)

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

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 (ReadOnlySpan<byte> utf8Text);
public readonly bool ValueTextEquals (ReadOnlySpan<byte> utf8Text);

Parameters

utf8Text
ReadOnlySpan<Byte>

The UTF-8 encoded text to compare against.

Returns

true if the JSON token value in the source matches the UTF-8 encoded lookup text; otherwise, false.

Exceptions

The JSON token is not a JSON string (that is, it is not String or PropertyName).

Remarks

The lookup text must be valid UTF-8 text. Otherwise, this method could return true if the source has a string token containing invalid UTF-8 text that matches.

The comparison of the JSON token value in the source and the lookup text is done by first unescaping the JSON value in source, if required. The lookup text is matched as is, without any modifications to it.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

ValueTextEquals(ReadOnlySpan<Char>)

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

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.

public bool ValueTextEquals (ReadOnlySpan<char> text);
public readonly bool ValueTextEquals (ReadOnlySpan<char> text);

Parameters

text
ReadOnlySpan<Char>

The text to compare against.

Returns

true if the JSON token value in the source matches the lookup text; otherwise, false.

Exceptions

The JSON token is not a JSON string (that is, it is not String or PropertyName).

Remarks

If the lookup text is invalid or incomplete UTF-16 text (that is, unpaired surrogates), the method returns false since you can't have invalid UTF-16 within the JSON payload.

The comparison of the JSON token value in the source and the lookup text is done by first unescaping the JSON value in source, if required. The lookup text is matched as is, without any modifications to it.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

ValueTextEquals(String)

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

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 (string? text);
public readonly bool ValueTextEquals (string? text);
public bool ValueTextEquals (string text);

Parameters

text
String

The text to compare against.

Returns

true if the JSON token value in the source matches the lookup text; otherwise, false.

Exceptions

The JSON token is not a JSON string (that is, it is not String or PropertyName).

Remarks

If the lookup text is invalid or incomplete UTF-16 text (that is, unpaired surrogates), the method returns false since you can't have invalid UTF-16 within the JSON payload.

The comparison of the JSON token value in the source and the lookup text is done by first unescaping the JSON value in source, if required. The lookup text is matched as is, without any modifications to it.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)