Skip to content

JsonElement.GetProperty Method

Definition

Namespace: Corvus.Text.Json
Assembly: Corvus.Text.Json.dll

Overloads

Method Description
GetProperty(string) Gets a JsonElement representing the value of a required property identified by propertyName.
GetProperty(ReadOnlySpan<char>) Gets a JsonElement representing the value of a required property identified by propertyName.
GetProperty(ReadOnlySpan<byte>) Gets a JsonElement representing the value of a required property identified by utf8PropertyName.

GetProperty(string)

Source: JsonElement.cs

Gets a JsonElement representing the value of a required property identified by propertyName.

public JsonElement GetProperty(string propertyName)

Parameters

Name Type Description
propertyName string Name of the property whose value to return.

Returns

JsonElement

A JsonElement representing the value of the requested property.

Exceptions

Exception Description
InvalidOperationException This value's ValueKind is not Object.
KeyNotFoundException No property was found with the requested name.
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

GetProperty(ReadOnlySpan<char>)

Source: JsonElement.cs

Gets a JsonElement representing the value of a required property identified by propertyName.

public JsonElement GetProperty(ReadOnlySpan<char> propertyName)

Parameters

Name Type Description
propertyName ReadOnlySpan<char> Name of the property whose value to return.

Returns

JsonElement

A JsonElement representing the value of the requested property.

Exceptions

Exception Description
InvalidOperationException This value's ValueKind is not Object.
KeyNotFoundException No property was found with the requested name.
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

GetProperty(ReadOnlySpan<byte>)

Source: JsonElement.cs

Gets a JsonElement representing the value of a required property identified by utf8PropertyName.

public JsonElement GetProperty(ReadOnlySpan<byte> utf8PropertyName)

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.

Returns

JsonElement

A JsonElement representing the value of the requested property.

Exceptions

Exception Description
InvalidOperationException This value's ValueKind is not Object.
KeyNotFoundException No property was found with the requested name.
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