public bool TryGetUInt64(out ulong value) { if (TokenType != JsonTokenType.Number) { ThrowHelper.ThrowInvalidOperationException_ExpectedNumber(TokenType); } ReadOnlySpan <byte> span = HasValueSequence ? ValueSequence.ToArray() : ValueSpan; return(TryGetUInt64Core(out value, span)); }
/// <summary> /// Parses the current JSON token value from the source as a <see cref="float"/>. /// Returns <see langword="true"/> if the entire UTF-8 encoded token value can be successfully /// parsed to a <see cref="float"/> value. /// Returns <see langword="false"/> otherwise. /// </summary> /// <exception cref="InvalidOperationException"> /// Thrown if trying to get the value of a JSON token that is not a <see cref="JsonTokenType.Number"/>. /// <seealso cref="TokenType" /> /// </exception> public bool TryGetSingle(out float value) { if (TokenType != JsonTokenType.Number) { ThrowHelper.ThrowInvalidOperationException_ExpectedNumber(TokenType); } ReadOnlySpan <byte> span = HasValueSequence ? ValueSequence.ToArray() : ValueSpan; if (Utf8Parser.TryParse(span, out float tmp, out int bytesConsumed) && span.Length == bytesConsumed) { value = tmp; return(true); } value = 0; return(false); }