feat: rename jsonc → jsonx, add JSONL API#99
Merged
Conversation
- git mv jsonc/ → jsonx/, jsonc.py → jsonx.py - Update module docstring to 'Extended JSON parser' - Add JSONL API: loads_lines, load_lines, dumps_lines, dump_lines - Each line preprocessed through JSONC pipeline (comments + trailing commas) - Blank and pure-comment lines skipped - Rename tests: test_jsonc_* → test_jsonx_*, update imports - Add JSONL correctness tests (multiline, blank lines, comment lines, inline comments, mixed types, trailing commas, roundtrip, error) - Add JSONL benchmark (vs jsonlines + ndjson) - pyproject.toml: bench-jsonc → bench-jsonx, add jsonlines/ndjson deps, testpaths jsonc → jsonx, ty extra-paths jsonc → jsonx - Add replaced_by mechanism in zerodep.py: - cmd_add: 'zerodep add jsonc' auto-installs jsonx with warning - cmd_outdated: detects local jsonc.py and suggests migration - Version kept at 0.3.0 (bump deferred to post-merge)
- deps frontmatter: jsonc → jsonx (version unchanged at 0.3.0) - _load_jsonc_loader → _load_jsonx_loader with jsonx-first, jsonc-fallback - all call sites updated
- config/config.py: wrap docstring to stay under 88-char line limit - jsonx/test_jsonx_benchmark.py: apply ruff format
Use ndjson-style batch parsing: join non-empty lines into a JSON array and parse in a single json.loads call. Falls back to per-line JSONC processing only when the batch parse fails (comments, trailing commas, etc.). Benchmark improvement on clean JSONL: - 10 lines: 16.5 µs → 5.1 µs (3.2x, faster than ndjson) - 1000 lines: 1982 µs → 516 µs (3.8x, on par with ndjson)
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #95
Changes (Milo's part)
jsonx module
git mv jsonc/ → jsonx/,jsonc.py → jsonx.pyloads_lines,load_lines,dumps_lines,dump_lines//,#) are skippedTests & benchmarks
test_jsonc_*→test_jsonx_*, updated importsjsonlines+ndjsonpyproject.toml:bench-jsonc→bench-jsonx, addedjsonlines/ndjsondeps,testpaths/ty extra-pathsupdatedCLI replaced_by
_REPLACED_BYmap inzerodep.pycmd_add:zerodep add jsoncauto-installsjsonxwith warningcmd_outdated: detects localjsonc.pyand shows migration hintNot touched (per instructions)
0.3.0manifest.jsonnot touched (deferred tomake manifest)config/module changes → Clementine's PR94 tests passing, ruff clean.