JsonNode.GetValue<T> Method

Definition

Gets the value for the current JsonValue.

C#
public virtual T GetValue<T> ();

Type Parameters

T

The type of the value to obtain from the JsonValue.

Returns

T

A value converted from the JsonValue instance.

Exceptions

The current JsonNode cannot be represented as a {TValue}.

The current JsonNode is not a JsonValue or is not compatible with {TValue}.

Remarks

{T} can be the type or base type of the underlying value. If the underlying value is a JsonElement then {T} can also be the type of any primitive value supported by current JsonElement.

Specifying the Object type for {T} will always succeed and return the underlying value as Object.

The underlying value of a JsonValue after deserialization is an instance of JsonElement,otherwise it's the value specified when the JsonValue was created.

Applies to

Produit Versions
.NET 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)