Skip to content

fix(bool): preserve fractional and exponential JSON number truth values - #382

Open
Twiink wants to merge 1 commit into
spf13:masterfrom
Twiink:fix/json-number-boolean
Open

Twiink wants to merge 1 commit into
spf13:masterfrom
Twiink:fix/json-number-boolean

Conversation

@Twiink

@Twiink Twiink commented Nov 29, 2026

Copy link
Copy Markdown

ToBoolE truncates json.Number through an integer conversion: a JSON value of 0.5 or -0.5 becomes false, while the same input decoded as float64 becomes true. Exponent notation also fails on the UseNumber path.

Use the existing float conversion before testing for zero. The regression decodes identical JSON with and without encoding/json.Decoder.UseNumber(), checks both boolean APIs, and retains zero/integer and invalid-input controls.

Validation: focused regression, go test -race ./..., go vet ./..., Go 1.21.13 full tests, and the repository-pinned golangci-lint 2.13.1 with Go 1.26.6 all pass.

AI disclosure: OpenAI Codex found this during an authorized code/issue sweep, implemented the change, reviewed the diff, and ran these checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant