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<TValue>() { throw null; }
+ public virtual T GetValue<T>() { 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; }
// 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
{
/// <summary>
/// Gets the value for the current <see cref="JsonValue"/>.
/// </summary>
+ /// <remarks>
+ /// {T} can be the type or base type of the underlying value.
+ /// If the underlying value is a <see cref="JsonElement"/> then {T} can also be the type of any primitive
+ /// value supported by current <see cref="JsonElement"/>.
+ /// Specifying the <see cref="object"/> type for {T} will always succeed and return the underlying value as <see cref="object"/>.<br />
+ /// The underlying value of a <see cref="JsonValue"/> after deserialization is an instance of <see cref="JsonElement"/>,
+ /// otherwise it's the value specified when the <see cref="JsonValue"/> was created.
+ /// </remarks>
+ /// <seealso cref="System.Text.Json.Nodes.JsonValue.TryGetValue"></seealso>
/// <exception cref="FormatException">
- /// The current <see cref="JsonNode"/> cannot be represented as a {TValue}.
+ /// The current <see cref="JsonNode"/> cannot be represented as a {T}.
/// </exception>
/// <exception cref="InvalidOperationException">
/// The current <see cref="JsonNode"/> is not a <see cref="JsonValue"/> or
- /// is not compatible with {TValue}.
+ /// is not compatible with {T}.
/// </exception>
- public virtual TValue GetValue<TValue>() =>
+ public virtual T GetValue<T>() =>
throw new InvalidOperationException(SR.Format(SR.NodeWrongType, nameof(JsonValue)));
/// <summary>
/// <summary>
/// Tries to obtain the current JSON value and returns a value that indicates whether the operation succeeded.
/// </summary>
+ /// <remarks>
+ /// {T} can be the type or base type of the underlying value.
+ /// If the underlying value is a <see cref="JsonElement"/> then {T} can also be the type of any primitive
+ /// value supported by current <see cref="JsonElement"/>.
+ /// Specifying the <see cref="object"/> type for {T} will always succeed and return the underlying value as <see cref="object"/>.<br />
+ /// The underlying value of a <see cref="JsonValue"/> after deserialization is an instance of <see cref="JsonElement"/>,
+ /// otherwise it's the value specified when the <see cref="JsonValue"/> was created.
+ /// </remarks>
+ /// <seealso cref="JsonNode.GetValue{T}"></seealso>
/// <typeparam name="T">The type of value to obtain.</typeparam>
/// <param name="value">When this method returns, contains the parsed value.</param>
/// <returns><see langword="true"/> if the value can be successfully obtained; otherwise, <see langword="false"/>.</returns>