JsonElement.TryGetProperty Method
Definition
Namespace: Corvus.Text.Json
Assembly: Corvus.Text.Json.dll
Overloads
| Method | Description |
|---|---|
| TryGetProperty(string, ref JsonElement) | Looks for a property named propertyName in the current object, returning whether or not such a property existed. When the property exists value is assigned to the value of that property. |
| TryGetProperty(ReadOnlySpan<char>, ref JsonElement) | Looks for a property named propertyName in the current object, returning whether or not such a property existed. When the property exists value is assigned to the value of that property. |
| TryGetProperty(ReadOnlySpan<byte>, ref JsonElement) | Looks for a property named utf8PropertyName in the current object, returning whether or not such a property existed. When the property exists value is assigned to the value of that property. |
TryGetProperty(string, ref JsonElement)
Source: JsonElement.cs
Looks for a property named propertyName in the current object, returning whether or not such a property existed. When the property exists value is assigned to the value of that property.
public bool TryGetProperty(string propertyName, ref JsonElement value)
Parameters
| Name | Type | Description |
|---|---|---|
propertyName |
string |
Name of the property to find. |
value |
ref JsonElement |
Receives the value of the located property. |
Returns
true if the property was found, false otherwise.
Exceptions
| Exception | Description |
|---|---|
InvalidOperationException |
This value's ValueKind is not Object. |
ArgumentNullException |
propertyName is null. |
ObjectDisposedException |
The parent JsonDocument has been disposed. |
Remarks
Property name matching is performed as an ordinal, case-sensitive, comparison. If a property is defined multiple times for the same object, the last such definition is what is matched.
Applies To
| Product | Versions |
|---|---|
| .NET | 9, 10 |
| .NET Standard | 2.0, 2.1 |
TryGetProperty(ReadOnlySpan<char>, ref JsonElement)
Source: JsonElement.cs
Looks for a property named propertyName in the current object, returning whether or not such a property existed. When the property exists value is assigned to the value of that property.
public bool TryGetProperty(ReadOnlySpan<char> propertyName, ref JsonElement value)
Parameters
| Name | Type | Description |
|---|---|---|
propertyName |
ReadOnlySpan<char> |
Name of the property to find. |
value |
ref JsonElement |
Receives the value of the located property. |
Returns
true if the property was found, false otherwise.
Exceptions
| Exception | Description |
|---|---|
InvalidOperationException |
This value's ValueKind is not Object. |
ObjectDisposedException |
The parent JsonDocument has been disposed. |
Remarks
Property name matching is performed as an ordinal, case-sensitive, comparison. If a property is defined multiple times for the same object, the last such definition is what is matched.
Applies To
| Product | Versions |
|---|---|
| .NET | 9, 10 |
| .NET Standard | 2.0, 2.1 |
TryGetProperty(ReadOnlySpan<byte>, ref JsonElement)
Source: JsonElement.cs
Looks for a property named utf8PropertyName in the current object, returning whether or not such a property existed. When the property exists value is assigned to the value of that property.
public bool TryGetProperty(ReadOnlySpan<byte> utf8PropertyName, ref JsonElement value)
Parameters
| Name | Type | Description |
|---|---|---|
utf8PropertyName |
ReadOnlySpan<byte> |
The UTF-8 (with no Byte-Order-Mark (BOM)) representation of the name of the property to return. |
value |
ref JsonElement |
Receives the value of the located property. |
Returns
true if the property was found, false otherwise.
Exceptions
| Exception | Description |
|---|---|
InvalidOperationException |
This value's ValueKind is not Object. |
ObjectDisposedException |
The parent JsonDocument has been disposed. |
Remarks
Property name matching is performed as an ordinal, case-sensitive, comparison. If a property is defined multiple times for the same object, the last such definition is what is matched.
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