Skip to content

BigNumber.TryParseJsonUtf8 Method

Definition

Namespace: Corvus.Numerics
Assembly: Corvus.Text.Json.dll
Source: BigNumber.OptimizedFormatting.cs

TryParseJsonUtf8(ReadOnlySpan<byte>, ref BigNumber)

Tries to parse a BigNumber from UTF-8 bytes in JSON format with zero allocations.

public static bool TryParseJsonUtf8(ReadOnlySpan<byte> utf8Source, ref BigNumber result)

Parameters

Name Type Description
utf8Source ReadOnlySpan<byte> The UTF-8 bytes to parse.
result ref BigNumber The parsed BigNumber.

Returns

bool

true if parsing succeeded; otherwise, false.

Remarks

This method is optimized for parsing JSON-formatted numbers with InvariantCulture semantics. It expects input in formats like: "123", "-456", "1234E-3", "1234E2", "0". The method parses directly from UTF-8 bytes without conversion to chars, maintaining zero heap allocations for typical numbers.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create and review issues and pull requests.

Open an issue