Skip to content

feat: rename jsonc → jsonx, add JSONL API#99

Merged
Oaklight merged 4 commits into
masterfrom
feature/jsonx-rename-95
Jun 12, 2026
Merged

feat: rename jsonc → jsonx, add JSONL API#99
Oaklight merged 4 commits into
masterfrom
feature/jsonx-rename-95

Conversation

@milo-oaklight

@milo-oaklight milo-oaklight Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Closes #95

Changes (Milo's part)

jsonx module

  • git mv jsonc/ → jsonx/, jsonc.py → jsonx.py
  • Module docstring updated to "Extended JSON parser"
  • New JSONL API: loads_lines, load_lines, dumps_lines, dump_lines
    • Each line preprocessed through JSONC pipeline (comments + trailing commas work)
    • Blank and pure-comment lines (//, #) are skipped

Tests & benchmarks

  • Renamed test_jsonc_*test_jsonx_*, updated imports
  • Added JSONL correctness tests: multiline, blank lines, comment lines, inline comments, mixed types, trailing commas, roundtrip, error handling
  • Added JSONL benchmark vs jsonlines + ndjson
  • pyproject.toml: bench-jsoncbench-jsonx, added jsonlines/ndjson deps, testpaths/ty extra-paths updated

CLI replaced_by

  • _REPLACED_BY map in zerodep.py
  • cmd_add: zerodep add jsonc auto-installs jsonx with warning
  • cmd_outdated: detects local jsonc.py and shows migration hint

Not touched (per instructions)

  • frontmatter version stays 0.3.0
  • manifest.json not touched (deferred to make manifest)
  • config/ module changes → Clementine's PR

94 tests passing, ruff clean.

milo-oaklight Bot and others added 4 commits June 12, 2026 09:43
- 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)
@Oaklight Oaklight merged commit c8002fe into master Jun 12, 2026
6 checks passed
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.

Rename jsonc → jsonx, add JSONL/NDJSON support

1 participant