Summary
Rename the jsonc module to jsonx ("extended JSON") and add JSONL/NDJSON parsing support.
Motivation
- Current
jsonc module only handles single JSON documents with comments/trailing commas
- JSONL (JSON Lines / NDJSON) is widely used for LLM training data, structured logs, and streaming — but not supported
- Renaming now (while adoption is small) avoids future breakage when adding more JSON variants
Affected repos (from scan)
Direct users: ToolRegistry, matrixd, zerodep/config (vendored _vendor/jsonc.py)
Hand-rolled equivalent: llm-rosetta (_strip_jsonc_comments() in gateway/config.py)
Indirect (via ToolRegistry): toolregistry-hub, toolregistry-server
Scope
1. Rename jsonc/ → jsonx/
- Rename directory and module file
- Update
manifest.json entry
- Update internal imports (zerodep
config module references jsonc)
2. Add JSONL/NDJSON support
New public API:
from jsonx import loads_lines, load_lines # JSONL/NDJSON parsing
from jsonx import dumps_lines, dump_lines # JSONL/NDJSON serialization
loads_lines(text) → list[Any] — parse multi-line JSONL string
load_lines(fp) → list[Any] — parse JSONL from file-like object
dumps_lines(items) → str — serialize list to JSONL string
dump_lines(items, fp) → write JSONL to file-like object
- Each line goes through the existing JSONC preprocessor (comments + trailing commas stripped), so JSONL-with-comments works out of the box
3. CLI backward compatibility
Add replaced_by mechanism to manifest.json + CLI:
- Old
jsonc manifest entry gets "replaced_by": "jsonx"
zerodep add jsonc → installs jsonx with a note
zerodep outdated → detects local jsonc.py, shows rename suggestion
- No symlink needed
4. Update tests & benchmarks
- Rename test files:
test_jsonc_* → test_jsonx_*
- Correctness tests: add JSONL cases (multi-line, empty lines, comments in JSONL, mixed types)
- Benchmark: add JSONL benchmarks comparing against:
jsonlines (most popular JSONL lib)
ndjson (API closest to stdlib json style)
- Keep existing JSONC benchmarks against
commentjson
5. Downstream migration (separate PRs)
- ToolRegistry —
_vendor/jsonc.py → _vendor/jsonx.py
- matrixd —
_vendor/jsonc.py → _vendor/jsonx.py
- zerodep/config — internal import update
- llm-rosetta — replace hand-rolled
_strip_jsonc_comments() with jsonx
Non-goals
- JSON5 support (future consideration, significantly more work)
- Binary formats (BSON, CBOR, MessagePack — different domain)
- Streaming/iterator API (can add later if needed)
Existing API (preserved, re-exported from jsonx)
loads(), load() — JSONC single-document parsing
dumps(), dump() — JSON serialization (stdlib passthrough)
JSONCDecodeError — error class with line-number remapping
Summary
Rename the
jsoncmodule tojsonx("extended JSON") and add JSONL/NDJSON parsing support.Motivation
jsoncmodule only handles single JSON documents with comments/trailing commasAffected repos (from scan)
Direct users: ToolRegistry, matrixd, zerodep/config (vendored
_vendor/jsonc.py)Hand-rolled equivalent: llm-rosetta (
_strip_jsonc_comments()ingateway/config.py)Indirect (via ToolRegistry): toolregistry-hub, toolregistry-server
Scope
1. Rename
jsonc/→jsonx/manifest.jsonentryconfigmodule referencesjsonc)2. Add JSONL/NDJSON support
New public API:
loads_lines(text)→list[Any]— parse multi-line JSONL stringload_lines(fp)→list[Any]— parse JSONL from file-like objectdumps_lines(items)→str— serialize list to JSONL stringdump_lines(items, fp)→ write JSONL to file-like object3. CLI backward compatibility
Add
replaced_bymechanism tomanifest.json+ CLI:jsoncmanifest entry gets"replaced_by": "jsonx"zerodep add jsonc→ installsjsonxwith a notezerodep outdated→ detects localjsonc.py, shows rename suggestion4. Update tests & benchmarks
test_jsonc_*→test_jsonx_*jsonlines(most popular JSONL lib)ndjson(API closest to stdlib json style)commentjson5. Downstream migration (separate PRs)
_vendor/jsonc.py→_vendor/jsonx.py_vendor/jsonc.py→_vendor/jsonx.py_strip_jsonc_comments()withjsonxNon-goals
Existing API (preserved, re-exported from jsonx)
loads(),load()— JSONC single-document parsingdumps(),dump()— JSON serialization (stdlib passthrough)JSONCDecodeError— error class with line-number remapping