Skip to content

JsonElement.Item Property

Definition

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

Overloads

Property Description
this[int] Get the value at a specified index when the current value is a Array.
this[ReadOnlySpan<byte>] Gets the value of the property with the given UTF-8 encoded name when the current value is an Object.
this[ReadOnlySpan<char>] Gets the value of the property with the given name when the current value is an Object.
this[string] Gets the value of the property with the given name when the current value is an Object.

this[int]

Source: JsonElement.cs

Get the value at a specified index when the current value is a Array.

public JsonElement this[int index] { get; }

Parameters

Name Type Description
index int

Returns

JsonElement

Exceptions

Exception Description
InvalidOperationException This value's ValueKind is not Array.
IndexOutOfRangeException index is not in the range [0, GetArrayLength()).
ObjectDisposedException The parent JsonDocument has been disposed.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

this[ReadOnlySpan<byte>]

Source: JsonElement.cs

Gets the value of the property with the given UTF-8 encoded name when the current value is an Object.

public JsonElement this[ReadOnlySpan<byte> propertyName] { get; }

Parameters

Name Type Description
propertyName ReadOnlySpan<byte> The UTF-8 (with no Byte-Order-Mark (BOM)) representation of the name of the property.

Returns

JsonElement

The value of the property with the given name, or a default JsonElement if no such property exists.

Exceptions

Exception Description
InvalidOperationException This value's ValueKind is not Object.
ObjectDisposedException The parent JsonDocument has been disposed.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

this[ReadOnlySpan<char>]

Source: JsonElement.cs

Gets the value of the property with the given name when the current value is an Object.

public JsonElement this[ReadOnlySpan<char> propertyName] { get; }

Parameters

Name Type Description
propertyName ReadOnlySpan<char> The name of the property.

Returns

JsonElement

The value of the property with the given name, or a default JsonElement if no such property exists.

Exceptions

Exception Description
InvalidOperationException This value's ValueKind is not Object.
ObjectDisposedException The parent JsonDocument has been disposed.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

this[string]

Source: JsonElement.cs

Gets the value of the property with the given name when the current value is an Object.

public JsonElement this[string propertyName] { get; }

Parameters

Name Type Description
propertyName string The name of the property.

Returns

JsonElement

The value of the property with the given name, or a default JsonElement if no such property exists.

Exceptions

Exception Description
InvalidOperationException This value's ValueKind is not Object.
ObjectDisposedException The parent JsonDocument has been disposed.
ArgumentNullException propertyName is null.

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