diff --git a/src/libraries/System.Text.Json/ref/System.Text.Json.cs b/src/libraries/System.Text.Json/ref/System.Text.Json.cs index 99a987c579291..757d8d63d5133 100644 --- a/src/libraries/System.Text.Json/ref/System.Text.Json.cs +++ b/src/libraries/System.Text.Json/ref/System.Text.Json.cs @@ -595,7 +595,7 @@ public abstract partial class JsonNode public System.Text.Json.Nodes.JsonObject AsObject() { throw null; } public System.Text.Json.Nodes.JsonValue AsValue() { throw null; } public string GetPath() { throw null; } - public virtual TValue GetValue() { throw null; } + public virtual T GetValue() { throw null; } public static explicit operator bool (System.Text.Json.Nodes.JsonNode value) { throw null; } public static explicit operator byte (System.Text.Json.Nodes.JsonNode value) { throw null; } public static explicit operator char (System.Text.Json.Nodes.JsonNode value) { throw null; } diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonNode.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonNode.cs index 6de74aef8ec3b..71ccc3f4b24b3 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonNode.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonNode.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; namespace System.Text.Json.Nodes { @@ -165,14 +164,23 @@ public JsonNode Root /// /// Gets the value for the current . /// + /// + /// {T} can be the type or base type of the underlying value. + /// If the underlying value is a then {T} can also be the type of any primitive + /// value supported by current . + /// Specifying the type for {T} will always succeed and return the underlying value as .
+ /// The underlying value of a after deserialization is an instance of , + /// otherwise it's the value specified when the was created. + ///
+ /// /// - /// The current cannot be represented as a {TValue}. + /// The current cannot be represented as a {T}. /// /// /// The current is not a or - /// is not compatible with {TValue}. + /// is not compatible with {T}. /// - public virtual TValue GetValue() => + public virtual T GetValue() => throw new InvalidOperationException(SR.Format(SR.NodeWrongType, nameof(JsonValue))); /// diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonValue.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonValue.cs index 1d0eb05631c47..87b6953f46765 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonValue.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonValue.cs @@ -99,6 +99,15 @@ internal override void GetPath(List path, JsonNode? child) /// /// Tries to obtain the current JSON value and returns a value that indicates whether the operation succeeded. /// + /// + /// {T} can be the type or base type of the underlying value. + /// If the underlying value is a then {T} can also be the type of any primitive + /// value supported by current . + /// Specifying the type for {T} will always succeed and return the underlying value as .
+ /// The underlying value of a after deserialization is an instance of , + /// otherwise it's the value specified when the was created. + ///
+ /// /// The type of value to obtain. /// When this method returns, contains the parsed value. /// if the value can be successfully obtained; otherwise, .