Skip to content

JsonBsonEncoder: fix parsing of JsonPrimitive numbers#1937

Open
berlix wants to merge 1 commit intomongodb:mainfrom
berlix:fix-json-primitive-numbers
Open

JsonBsonEncoder: fix parsing of JsonPrimitive numbers#1937
berlix wants to merge 1 commit intomongodb:mainfrom
berlix:fix-json-primitive-numbers

Conversation

@berlix
Copy link
Copy Markdown

@berlix berlix commented Apr 9, 2026

encodeJsonPrimitive would in some cases attempt to parse scientifically formatted numbers as plain Ints/Longs, which would result in a NumberFormatException.

The new test case testJsonPrimitiveNumberEncoding reproduces the issue/verifies the fix.

Note that the adjusted implementation always encodes numbers with the least amount of decimals necessary, which is why some other test cases needed to be adjusted.

encodeJsonPrimitive would in some cases attempt to parse scientifically formatted numbers as plain Ints/Longs, which would result in a NumberFormatException.
@berlix berlix requested a review from a team as a code owner April 9, 2026 14:04
@berlix berlix requested a review from stIncMale April 9, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants