Add Object JsonParser.getNumberValueDeferred()
method to allow for deferred decoding in some cases
#902
Milestone
Object JsonParser.getNumberValueDeferred()
method to allow for deferred decoding in some cases
#902
(note: alternative take on #893)
Accessing numeric value from
JsonParser
can be done either using typed accessors (getLongValue()
) or using genericNumber 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 returnString
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 beTokenBuffer
class injackson-databind
; and it will further use integer-or-floating-point distinction (wrtJsonParser.currentToken()
) to figure out possible types.Base implementation in
JsonParser
, for backwards compatibility, should be to simple callgetNumberValue()
, return that: subtypes that support deferred parsing then need to override this.The text was updated successfully, but these errors were encountered: