Repository navigation
fix: preserve exact numbers in JSON tree view - #179
Conversation
anurag629
left a comment
There was a problem hiding this comment.
Thanks @kudala-bharani, this does everything #122 asks. I merged it onto current develop: lint shows only the 13 old warnings, all 251 tests pass, and with the fix taken out 9 of the new tests fail. Rendering the real tree with react-dom/server is a nice way to cover this without a new dependency. Since the PR adds an @ alias to the vitest config, I'll update the line in CONTRIBUTING that says there isn't one. Merging.
That's your 5th merged PR this month, so you qualify for the CODERCOPS swag (our own program, separate from Hacktoberfest), which goes to the top 5 at the end of October. We DM the winners on Discord, so please join the server and run /link there to connect your GitHub. The invite is on https://oss.codercops.com/leaderboard/2026-10.
What and why
Closes #122.
Tree view now uses the existing lossless-json parser and displays
LosslessNumbervalues as numeric leaves with their exact text. Large integers and long decimals keep the same digits as Code view instead of being rounded or shown as expandable objects.The checks use
instanceof LosslessNumberso an ordinary JSON object with a field namedisLosslessNumberstill renders as an object.How I tested this
react-dom/server: the issue's example, numeric roots, nested values, overflow/underflow, negative zero, trailing zeros, ordinary JSON values, collapsed containers, invalid JSON, and objects with number-like field names.npm run lintpasses with 13 existing warnings in unchanged files; all changed files pass with zero warnings.npm run test: 251 tests pass.npm run build: passes on Node 22, including TypeScript and page generation.AI assistance
Used OpenAI Codex to implement the fix and regression tests, review the diff, and run the checks above.
Type of change
Checklist
npm run lint && npm run test && npm run buildpasses locallyNotes for reviewers
No new dependencies.
TreeViewis exported for the render tests, and Vitest gets the same@alias the app already uses. Parsing stays in the component; no shared conversion logic changed.