Skip to content

feat(toon): implement TOON 4.4 and fix list-form nested objects - #227

Merged
Oaklight merged 1 commit into
masterfrom
feature/toon-spec-4.4
Oct 22, 2026
Merged

Oaklight merged 1 commit into
masterfrom
feature/toon-spec-4.4

Conversation

@Oaklight

Copy link
Copy Markdown
Owner

What

Bring toon/ to TOON 4.4 and close #188 as part of the rebuild.

  • Encoder and decoder rebuilt on the reference implementation's algorithms (toon-format/toon-python@91413d14, MIT; attributed in the module docstring).
  • Official spec 4.4 fixtures: 564/564 pass (was 359/564); toon/conformance_baseline.json is empty.
  • List form now round-trips nested object values (toon: the list form does not round-trip a nested object value #188): [{'d': {}}] encodes as - d: and decodes back instead of dropping d, and arrays of objects with differently-keyed sub-objects decode their own encoder output. Item headers put the first key on the hyphen line, matching the reference.
  • lengthMarker was removed by the specification: encoders never emit [#N], decoders reject it, and passing the option raises ValueError (migration note in the docs).
  • Values outside the JSON data model (for example a callable) now raise TypeError instead of silently encoding as null, matching the reference and json.dumps.
  • bench-toon pin raised to toon-python@91413d14 (spec 4.4).
  • toon bumped to 0.6.0; manifest.json regenerated.

Verification

  • pytest toon --ignore-glob="*/test_*_benchmark.py": 148 passed, against both the previously pinned reference and the 4.4 reference.
  • Conformance gate: 564/564.
  • pre-commit run --all-files: ruff, ruff-format, ty, complexipy pass.
  • Benchmarks vs the 4.4 reference: encode parity to ~1.3x faster on large data, decode parity.
  • zerodep version-check: all modules up-to-date.

Docs (module page, benchmark page, changelog; EN and ZH) are committed on docs_en / docs_zh.

Fixes #184
Fixes #188

AI was used to assist with this change.

Rebuild the encoder and decoder on the reference implementation's
algorithms (toon-format/toon-python@91413d14, MIT) so the module emits and
reads the current format.  The vendored spec 4.4 fixtures pass 564/564
(was 359/564), and the conformance baseline is empty.

Fixes #188 as part of the rebuild: the list form writes an item's first
key on the hyphen line ("- d:") and its decoder rebuilds the nested
block, so [{'d': {}}] and arrays of objects with differently-keyed
sub-objects round-trip instead of dropping data or raising.

The spec removed the pre-4.0 [#N] length marker: encoding with
lengthMarker now raises ValueError.  Values outside the JSON data model
(for example a callable) raise TypeError instead of encoding as null,
matching the reference.  Raise the bench-toon pin to the spec 4.4 commit
and bump toon to 0.6.0.

Fixes #184
@Oaklight
Oaklight merged commit a37e656 into master Oct 22, 2026
6 checks passed
@Oaklight
Oaklight deleted the feature/toon-spec-4.4 branch October 22, 2026 22:04
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.

toon: the list form does not round-trip a nested object value toon: bring the module to TOON spec 4.4, or label it as a pre-4.0 implementation

1 participant