Skip to content

Add Object JsonParser.getNumberValueDeferred() method to allow for deferred decoding in some cases #902

@cowtowncoder

Description

@cowtowncoder

(note: alternative take on #893)

Accessing numeric value from JsonParser can be done either using typed accessors (getLongValue()) or using generic Number JsonParser.getNumberValue(). But in both of these cases access forces decoding of the actual numeric value.
But there are cases where it would be nice to only get actual Number if it has already been decoded; otherwise return String representation of the number.

Although there is no super nice way in Java to support "either" type, I think in this case it is fine to simply indicate type as Object and let caller do type-casting: main initial user will be TokenBuffer class in jackson-databind; and it will further use integer-or-floating-point distinction (wrt JsonParser.currentToken()) to figure out possible types.

Base implementation in JsonParser, for backwards compatibility, should be to simple call getNumberValue(), return that: subtypes that support deferred parsing then need to override this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions