JsonElement.GetProperty Method

Definition

Overloads

GetProperty(ReadOnlySpan<Byte>)

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

GetProperty(ReadOnlySpan<Char>)

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

GetProperty(String)

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

GetProperty(ReadOnlySpan<Byte>)

Source:
JsonElement.cs
Source:
JsonElement.cs
Source:
JsonElement.cs
Source:
JsonElement.cs
Source:
JsonElement.cs

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

public System.Text.Json.JsonElement GetProperty (ReadOnlySpan<byte> utf8PropertyName);

Parameters

utf8PropertyName
ReadOnlySpan<Byte>

The UTF-8 representation (with no Byte-Order-Mark (BOM)) of the name of the property to return.

Returns

A JsonElement representing the value of the requested property.

Exceptions

No property was found with the requested name.

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 method matches the last such definition.

For more information, see How to write custom serializers and deserializers with System.Text.Json.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

GetProperty(ReadOnlySpan<Char>)

Source:
JsonElement.cs
Source:
JsonElement.cs
Source:
JsonElement.cs
Source:
JsonElement.cs
Source:
JsonElement.cs

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

public System.Text.Json.JsonElement GetProperty (ReadOnlySpan<char> propertyName);

Parameters

propertyName
ReadOnlySpan<Char>

The name of the property whose value is to be returned.

Returns

A JsonElement representing the value of the requested property.

Exceptions

No property was found with the requested name.

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 method matches the last such definition.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

GetProperty(String)

Source:
JsonElement.cs
Source:
JsonElement.cs
Source:
JsonElement.cs
Source:
JsonElement.cs
Source:
JsonElement.cs

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

public System.Text.Json.JsonElement GetProperty (string propertyName);

Parameters

propertyName
String

The name of the property whose value is to be returned.

Returns

A JsonElement representing the value of the requested property.

Exceptions

No property was found with the requested name.

propertyName is null.

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 method matches the last such definition.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)