Skip to content

Rename jsonc → jsonx, add JSONL/NDJSON support #95

@milo-oaklight

Description

@milo-oaklight

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions