Class JsonNumberNotation
A number written in scientific notation is a DOUBLE and a number written plainly is not — the rule
is the notation itself, with nothing to do with the value: live, PARSE_JSON('[1.0e0]') is
[1.0] with TYPEOF DOUBLE while PARSE_JSON('[1.0]') is [1] with TYPEOF INTEGER,
and [2e0], [0e0], [1.0E0], [1.0e+0] and [1.0e1] are all DOUBLE
too. The sign and magnitude of the exponent never enter into it.
THE NOTATION DOES NOT SURVIVE THE PARSE, which is the whole reason this class exists. A JSON reader
hands back a BigDecimal, and 1.0e0 and 1.0 produce the same one — unscaled 10, scale 1.
Only a NEGATIVE scale is recoverable afterwards (1e5 keeps scale −5), so everything with a zero
or small positive exponent was indistinguishable from its plain spelling and lost the family. The
digit-count stand-in that used to cover part of this — more than 15 significant digits reading as
double provenance — was measured WRONG in the other direction: live types the plain
[1.234567890123456] as DECIMAL.
So the notation is read from the TEXT, in a second streaming pass over the same document that
produced the tree, walking the two in lockstep and re-typing each float token written with an
exponent. The pass is skipped outright unless the text contains a digit or point followed by an
e. Duplicate object keys cannot desynchronise the walk because the reader refuses them
outright (a duplicate attribute is a live refusal), so a field is matched by NAME and an element by
position.
-
Method Summary
Modifier and TypeMethodDescriptionstatic tools.jackson.databind.JsonNodeapplyExponentNotation(tools.jackson.databind.ObjectMapper mapper, String text, tools.jackson.databind.JsonNode tree) The tree with every float that was WRITTEN with an exponent carried in the DOUBLE family.
-
Method Details
-
applyExponentNotation
public static tools.jackson.databind.JsonNode applyExponentNotation(tools.jackson.databind.ObjectMapper mapper, String text, tools.jackson.databind.JsonNode tree) The tree with every float that was WRITTEN with an exponent carried in the DOUBLE family.- Parameters:
mapper- the mapper whose reader producedtree— the second pass has to read the document under the same leniencies or it will not agree with the firsttext- the document exactly as the first pass read it, sentinels and relaxations includedtree- the parsed tree, mutated in place and returned; null is passed through- Returns:
- the tree, with exponent-written floats re-typed
-