Skip to content

JsonElement.EnumerateDescendantProperties Method

Definition

Namespace: Corvus.Text.Json
Assembly: Corvus.Text.Json.dll
Source: JsonElement.cs

EnumerateDescendantProperties(ReadOnlySpan<byte>)

Returns an enumerator that yields the values of all descendant properties whose unescaped name equals utf8PropertyName.

public DescendantPropertyEnumerator EnumerateDescendantProperties(ReadOnlySpan<byte> utf8PropertyName)

Parameters

Name Type Description
utf8PropertyName ReadOnlySpan<byte> The unescaped UTF-8 property name to search for.

Returns

DescendantPropertyEnumerator

A DescendantPropertyEnumerator that iterates the matching values in document order.

Exceptions

Exception Description
InvalidOperationException The element does not belong to a valid document instance.

Remarks

This method performs a flat linear scan over the metadata DB. It does not construct intermediate enumerators, check ValueKind, or recurse. For recursive-descent JSONPath queries ($..name), this is substantially faster than recursive EnumerateObject traversal. If the element is a scalar (not an object or array), the enumerator yields zero results.

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