Skip to content

Add support in TokenBuffer for lazily decoded (big) numbers #3730

Closed
@cowtowncoder

Description

@cowtowncoder

(note: for background see #3721)

There are a few issues with TokenBuffer regarding number coercions, mostly due to eager buffering sometimes needed, which forces decision on use of type (double vs BigDecimal in particular) before knowing target type.
There are also concerns about overhead in some cases, preventing efficient skipping of big number values in cases where buffering is needed: for example, when @JsonCreator use requires preservation of content that would ultimately be skipped.

An idea that came to mind is that since TokenBuffer stores all buffered content using 2 elements -- JsonToken for type, and opaque Object (depending on type) -- it would be possible to augment handling to use hypothetical BufferedNumber (or LazyNumber) type, which could:

  1. Store more information on actual NumberType (to preserve distinction between finer grain JsonParser exposes)
  2. Allow deferred decoding esp. for "big" numbers (BigInteger, all floating-point types)

This would require support from jackson-core for:

  • New type itself (BufferedNumber) as well as implementation(s) if not concrete
  • New accessor(s) from JsonParser -- either specific "always get buffered" or hybrid (buffered if not decoded; Number if decoded)

There are probably other subtleties too but this is the general idea. If anyone plans to work on this, another issue needs to be created on jackson-core side.

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