Skip to content

Add {Try}GetBigIntegerValue to Utf8JsonReader #1561

@ahsonkhan

Description

@ahsonkhan

Split off from https://github.com/dotnet/corefx/issues/33320#issuecomment-437046345.

We already have the following "convert to .NET type" APIs on Utf8JsonReader:

public ref partial struct Utf8JsonReader
{
// These throw InvalidOperationException if there is a token type mismatch
    public string GetStringValue();
    public bool GetBooleanValue();

// These throw InvalidOperationException if there is a token type mismatch (i.e. not JsonTokenType.Number).
    public bool TryGetInt32Value(out int value);
    public bool TryGetInt64Value(out long value);
    public bool TryGetSingleValue(out float value);
    public bool TryGetDoubleValue(out double value);
    public bool TryGetDecimalValue(out decimal value);
}

Add the following:

public ref partial struct Utf8JsonReader
{
// This throws InvalidOperationException if there is a token type mismatch (i.e. not JsonTokenType.Number).
    public bool TryGetBigIntegerValue(out BigInteger value);

// This throw InvalidOperationException if there is a token type mismatch.
// This throw OverflowException if the number isn't an integer.
    public BigInteger GetBigIntegerValue();
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions