/// <summary>Gets the current JSON number as a <see cref="double"/>.</summary> /// <returns>The current JSON number as a <see cref="double"/>.</returns> /// <remarks> /// <para> /// This method does not parse the contents of a JSON string value. /// </para> /// <para> /// On .NET Core this method returns <see cref="double.PositiveInfinity"/> (or /// <see cref="double.NegativeInfinity"/>) for values larger than /// <see cref="double.MaxValue"/> (or smaller than <see cref="double.MinValue"/>). /// </para> /// </remarks> /// <exception cref="InvalidOperationException"> /// This value's <see cref="ValueKind"/> is not <see cref="JsonValueKind.Number"/>. /// </exception> /// <exception cref="FormatException"> /// The value cannot be represented as a <see cref="double"/>. /// </exception> public double GetDouble() { if (TryGetDouble(out double value)) { return(value); } throw ThrowHelper.CreateFormatException_MalformedJson(); }
/// <summary>Gets the current JSON object as a <see cref="JwtDocument"/>.</summary> /// <returns>The current JSON object as a <see cref="JwtDocument"/>.</returns> /// <remarks> /// <para> /// This method does not parse the contents of a JSON string value. /// </para> /// </remarks> /// <exception cref="InvalidOperationException"> /// This value's <see cref="ValueKind"/> is not <see cref="JsonValueKind.Object"/>. /// </exception> /// <exception cref="FormatException"> /// The value cannot be represented as a <see cref="JwtDocument"/>. /// </exception> public JsonDocument GetJsonDocument() { if (TryGetJsonDocument(out JsonDocument? value)) { return(value); } throw ThrowHelper.CreateFormatException_MalformedJson(); }
/// <summary> /// Gets the current JSON number as a <see cref="long"/>. /// </summary> /// <returns>The current JSON number as a <see cref="long"/>.</returns> /// <remarks> /// This method does not parse the contents of a JSON string value. /// </remarks> /// <exception cref="InvalidOperationException"> /// This value's <see cref="ValueKind"/> is not <see cref="JsonValueKind.Number"/>. /// </exception> /// <exception cref="FormatException"> /// The value cannot be represented as a <see cref="long"/>. /// </exception> public long GetInt64() { if (TryGetInt64(out long value)) { return(value); } throw ThrowHelper.CreateFormatException_MalformedJson(); }