FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix flgBaseWriter to use kParseNumbersAsStringsFlag instead of kParseFullPrecisionFlag by AntonDevil · Pull Request #241 · NPP-JSONViewer/JSON-Viewer · GitHub

Fix flgBaseWriter to use kParseNumbersAsStringsFlag instead of kParseFullPrecisionFlag - #241

Merged
SinghRajenM merged 4 commits into
NPP-JSONViewer:masterfrom
AntonDevil:user/AntonDevil/FixflgBaseWriter
Mar 21, 2026
Merged

Fix flgBaseWriter to use kParseNumbersAsStringsFlag instead of kParseFullPrecisionFlag#241
SinghRajenM merged 4 commits into
NPP-JSONViewer:masterfrom
AntonDevil:user/AntonDevil/FixflgBaseWriter

Conversation

Copy link
Copy Markdown
Contributor

Preserve exact number text in Compress/Format operations

This PR was generated with the assistance of GitHub Copilot (Claude Opus 4.6).

Problem

flgBaseWriter (used by Compress, Format, and Validate) used kParseFullPrecisionFlag, which parsed numbers as double and re-serialized them. This caused:

  • Precision loss: 0.00000000000001 → 1e-14
  • Normalization: 1.234e5 → 123400.0
  • Rounding artifacts: -1722.1864265316147 → -1722.1864265316146
  • -Inf/Inf shorthand expanded to -Infinity/Infinity

Fix

Aligned flgBaseWriter with flgBaseReader — both now use kParseNumbersAsStringsFlag. Numbers pass through as exact original text in all operations (compress, format, sort-by-key).

Changes

  • JsonHandler.h: Changed flgBaseWriter from kParseFullPrecisionFlag to kParseNumbersAsStringsFlag, with comment explaining the history
  • JsonCompressTest.cpp: Updated Infinity and number precision expectations
  • JsonFormatTest.cpp: Updated Infinity and number precision expectations
  • JsonSortByKeyTest.cpp: Updated precision test for exact preservation, added TestSortJsonByKey_NumberFormats_Success covering all JSON number notations

Testing

All 95 plugin tests pass. All 477 RapidJSON tests pass.

SinghRajenM self-assigned this Mar 21, 2026

Copy link
Copy Markdown
Collaborator

Fixes #39 and Closes #39
Fixes #119 and Closes #119
Fixes #196 and Closes #196

SinghRajenM merged commit 0052c4f into NPP-JSONViewer:master Mar 21, 2026
9 checks passed
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL