Utf8JsonReader.ValueTextEquals Method
Definition
Namespace: Corvus.Text.Json
Assembly: Corvus.Text.Json.dll
Overloads
| Method | Description |
|---|---|
| ValueTextEquals(ReadOnlySpan<byte>) | Compares the UTF-8 encoded text to the unescaped JSON token value in the source and returns true if they match. |
| ValueTextEquals(string) | Compares the string text to the unescaped JSON token value in the source and returns true if they match. |
| ValueTextEquals(ReadOnlySpan<char>) | Compares the text to the unescaped JSON token value in the source and returns true if they match. |
ValueTextEquals(ReadOnlySpan<byte>)
Source: Utf8JsonReader.cs
Compares the UTF-8 encoded text to the unescaped JSON token value in the source and returns true if they match.
public bool ValueTextEquals(ReadOnlySpan<byte> utf8Text)
Parameters
| Name | Type | Description |
|---|---|---|
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 look up text.
Exceptions
| Exception | Description |
|---|---|
InvalidOperationException |
Thrown if trying to find a text match on a JSON token that is not a string (i.e. other than String or PropertyName). |
Remarks
If the look up text is invalid UTF-8 text, the method will return false since you cannot have invalid UTF-8 within the JSON payload. The comparison of the JSON token value in the source and the look up text is done by first unescaping the JSON value in source, if required. The look up text is matched as is, without any modifications to it.
Applies To
| Product | Versions |
|---|---|
| .NET | 9, 10 |
| .NET Standard | 2.0, 2.1 |
ValueTextEquals(string)
Source: Utf8JsonReader.cs
Compares the string text to the unescaped JSON token value in the source and returns true if they match.
public bool ValueTextEquals(string text)
Parameters
| Name | Type | Description |
|---|---|---|
text |
string |
The text to compare against. |
Returns
True if the JSON token value in the source matches the look up text.
Exceptions
| Exception | Description |
|---|---|
InvalidOperationException |
Thrown if trying to find a text match on a JSON token that is not a string (i.e. other than String or PropertyName). |
Remarks
If the look up text is invalid UTF-8 text, the method will return false since you cannot have invalid UTF-8 within the JSON payload. The comparison of the JSON token value in the source and the look up text is done by first unescaping the JSON value in source, if required. The look up text is matched as is, without any modifications to it.
Applies To
| Product | Versions |
|---|---|
| .NET | 9, 10 |
| .NET Standard | 2.0, 2.1 |
ValueTextEquals(ReadOnlySpan<char>)
Source: Utf8JsonReader.cs
Compares the text to the unescaped JSON token value in the source and returns true if they match.
public bool ValueTextEquals(ReadOnlySpan<char> text)
Parameters
| Name | Type | Description |
|---|---|---|
text |
ReadOnlySpan<char> |
The text to compare against. |
Returns
True if the JSON token value in the source matches the look up text.
Exceptions
| Exception | Description |
|---|---|
InvalidOperationException |
Thrown if trying to find a text match on a JSON token that is not a string (i.e. other than String or PropertyName). |
Remarks
If the look up text is invalid or incomplete UTF-16 text (i.e. unpaired surrogates), the method will return false since you cannot have invalid UTF-16 within the JSON payload. The comparison of the JSON token value in the source and the look up text is done by first unescaping the JSON value in source, if required. The look up text is matched as is, without any modifications to it.
Applies To
| Product | Versions |
|---|---|
| .NET | 9, 10 |
| .NET Standard | 2.0, 2.1 |
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests.
Open an issue