Repository navigation
Pretty printing and beneathPath change how JSON numbers are documented - #1078
Open
chuuminggg wants to merge 1 commit into
Open
chuuminggg wants to merge 1 commit into
chuuminggg wants to merge 1 commit into
Conversation
Previously, floating-point numbers in JSON content were read as doubles so pretty printing and beneathPath changed how they were documented. For example, 10.50 became 10.5 and values that cannot be represented exactly as a double lost precision. Such numbers are now read as BigDecimal so that their original value is retained. Signed-off-by: chuuminggg <rorrxr@naver.com>
chuuminggg
force-pushed
the
pretty-print-preserves-numbers
branch
from
October 16, 2026 10:37
80ae193 to
265b0d5
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
prettyPrint()andbeneathPath(…)read JSON with anObjectMapperthat usesdoublefor floating-point numbers. When the JSON is written back out, some numbers are documented with a different value or representation from the one in the actual request or response:{"price":10.50,"rate":1e3,"exact":0.1000000000000000055511151231257827,"big":12345678901234567890.123}becomes:
{ "price" : 10.5, "rate" : 1000.0, "exact" : 0.1, "big" : 1.2345678901234567E19 }The same happens to the subsection that's extracted by
beneathPath(…), which is used for the body and fields snippets. Trailing zeros are common in monetary amounts (10.50), so the documented payload can easily differ from what the API actually returns. High-precision and large decimal numbers lose precision.This PR enables
DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATSon theObjectMapperthat's used for reading inPrettyPrintingContentModifierandFieldPathPayloadSubsectionExtractor, so the numbers are kept asBigDecimal. All of the values above are then written exactly as they were in the input. The only remaining differences are in notation, which doesn't change the value:BigDecimal.toString()would write it, for example1E+3rather than1e3. Previously, it became1000.0.-0.0is written as0.0.Integers aren't affected, as they were already read as
int,long, orBigInteger.