JsonElement.ValueEquals Method
Definition
Namespace: Corvus.Text.Json
Assembly: Corvus.Text.Json.dll
Overloads
| Method | Description |
|---|---|
| ValueEquals(string) | Compares text to the string value of this element. |
| ValueEquals(ReadOnlySpan<byte>) | Compares the text represented by utf8Text to the string value of this element. |
| ValueEquals(ReadOnlySpan<char>) | Compares text to the string value of this element. |
ValueEquals(string)
Source: JsonElement.cs
Compares text to the string value of this element.
public bool ValueEquals(string text)
Parameters
| Name | Type | Description |
|---|---|---|
text |
string |
The text to compare against. |
Returns
true if the string value of this element matches text, false otherwise.
Exceptions
| Exception | Description |
|---|---|
InvalidOperationException |
This value's ValueKind is not String. |
Remarks
This method is functionally equal to doing an ordinal comparison of text and the result of calling GetString, but avoids creating the string instance.
Applies To
| Product | Versions |
|---|---|
| .NET | 9, 10 |
| .NET Standard | 2.0, 2.1 |
ValueEquals(ReadOnlySpan<byte>)
Source: JsonElement.cs
Compares the text represented by utf8Text to the string value of this element.
public bool ValueEquals(ReadOnlySpan<byte> utf8Text)
Parameters
| Name | Type | Description |
|---|---|---|
utf8Text |
ReadOnlySpan<byte> |
The UTF-8 encoded text to compare against. |
Returns
true if the string value of this element has the same UTF-8 encoding as utf8Text, false otherwise.
Exceptions
| Exception | Description |
|---|---|
InvalidOperationException |
This value's ValueKind is not String. |
Remarks
This method is functionally equal to doing an ordinal comparison of the string produced by UTF-8 decoding utf8Text with the result of calling GetString, but avoids creating the string instances.
Applies To
| Product | Versions |
|---|---|
| .NET | 9, 10 |
| .NET Standard | 2.0, 2.1 |
ValueEquals(ReadOnlySpan<char>)
Source: JsonElement.cs
Compares text to the string value of this element.
public bool ValueEquals(ReadOnlySpan<char> text)
Parameters
| Name | Type | Description |
|---|---|---|
text |
ReadOnlySpan<char> |
The text to compare against. |
Returns
true if the string value of this element matches text, false otherwise.
Exceptions
| Exception | Description |
|---|---|
InvalidOperationException |
This value's ValueKind is not String. |
Remarks
This method is functionally equal to doing an ordinal comparison of text and the result of calling GetString, but avoids creating the string instance.
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