Port round-trip bug fixes from Python ZON PR#9 to TypeScript
- [x] Confirm top-level objects bypass
_formatZonNode/_parseKeycode paths - [x] Update
boolean-keys.test.ts: wrap fixtures in{ wrapper: {...} }so tests exercise the patched code paths - [x] Replaced broken mixed-key array test with a multi-sibling-object test
- [x] All 311 tests pass
@coderabbitai look into this PR
@ronibhakta1 Sure! I'll start reviewing this PR now. I'll look into the three round-trip bug fixes ported from the Python ZON implementation — boolean-like dictionary keys, dictionary header value quoting, and the associated test coverage. I'll post my findings shortly.
✅ Actions performed
Review triggered.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
This PR adds test coverage and implementation improvements for ZON encoding/decoding edge cases, including boolean-like dictionary keys and special characters in headers. A new 🎯 3 (Moderate) | ⏱️ ~20 minutes 🐰 Keys and values, quite the pair!
We parse them with the utmost care.
No more ✏️ Tip: You can configure your own custom pre-merge checks in the settings.📝 Walkthrough
Walkthrough
parseKey utility function distinguishes key parsing from value parsing, with updates to encoder and decoder accordingly.Changes
Cohort / File(s)
Summary
Test Coverage
src/__tests__/boolean-keys.test.ts, src/__tests__/dict-header-quoting.test.tsNew Jest test suites validating encoding/decoding of boolean-like dictionary keys (
"true", "false", "null", etc.) and dictionary headers containing commas and colons, ensuring round-trip preservation of original string keys and field values.
Key Parsing Utility
src/core/utils.tsIntroduces
parseKey function for ZON dictionary keys that always returns strings, supporting double-quoted and single-quoted keys, with ZON-to-JSON escape sequence conversion, without boolean/null keyword conversion.
Decoder Key Handling
src/core/decoder.tsUpdates key parsing to use
_parseKey instead of _parseValue, and enhances dictionary handling by splitting and parsing dictionary values with awareness of quotes and nesting.
Encoder Key Quoting
src/core/encoder.tsAdds quoting of object keys that resemble boolean/null keywords (
true/false/t/f/null/none/nil, case-insensitive) to prevent misinterpretation; formats dictionary string values via _formatValue before emission.Estimated code review effort
Poem
"true" masquerading as a fact,
Each quoted key stays on its track.
Boolean-like keys now round-trip true,
The ZON encoder/decoder's breakthrough! ✨🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name
Status
Explanation
Title check
✅ Passed
The title accurately describes the main objective of the PR: porting round-trip bug fixes from the Python ZON implementation to TypeScript, which aligns with the substantial changes across encoder, decoder, and utilities.
Docstring Coverage
✅ Passed
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check
✅ Passed
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
✅ Passed
Check skipped because no linked issues were found for this pull request.
Description Check
✅ Passed
Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
📝 Generate docstrings
🧪 Generate unit tests (beta)
copilot/sync-with-other-package
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.