Add support in TokenBuffer for lazily decoded (big) numbers · Issue #3730 · FasterXML/jackson-databind (original) (raw)

(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:

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.