Problem
Older revisions of this backport included convenience constructors/factories on the core java.util.json types (notably around JsonNumber) that accepted BigDecimal / BigInteger. After the most recent sync from upstream openjdk/jdk-sandbox those APIs are no longer present.
This leaves users wondering:
- what happened to the BigDecimal/BigInteger entry points
- whether their removal was accidental vs. deliberate upstream design
- how to do lossless numeric handling without the constructor explosion typical of legacy OO APIs
Goal
Document the design choice: JSON numbers are represented primarily as lexical decimal text, with minimal numeric factories (double, long, String) and lossless conversion via toString().
Add runnable examples (and tests) showing:
- precision loss with
double
- lossless conversion using
BigDecimal/BigInteger via toString()
- how to build
JsonNumber from BigDecimal without adding new overloads
- how lexically-preserving
toString() differs from numeric normalization
Deliverables
DESIGN_CHOICES.md analysis with examples
- matching example sources under
json-java21/src/main/... and json-java21/src/test/...
Problem
Older revisions of this backport included convenience constructors/factories on the core
java.util.jsontypes (notably aroundJsonNumber) that acceptedBigDecimal/BigInteger. After the most recent sync from upstreamopenjdk/jdk-sandboxthose APIs are no longer present.This leaves users wondering:
Goal
Document the design choice: JSON numbers are represented primarily as lexical decimal text, with minimal numeric factories (
double,long,String) and lossless conversion viatoString().Add runnable examples (and tests) showing:
doubleBigDecimal/BigIntegerviatoString()JsonNumberfromBigDecimalwithout adding new overloadstoString()differs from numeric normalizationDeliverables
DESIGN_CHOICES.mdanalysis with examplesjson-java21/src/main/...andjson-java21/src/test/...