[RFC v4.0] Mixed columnar arrays, objectArrayLayout, ignoreNullOrEmpty, excludeEmptyArrays#47
Draft
vhafdal wants to merge 1 commit into
Draft
[RFC v4.0] Mixed columnar arrays, objectArrayLayout, ignoreNullOrEmpty, excludeEmptyArrays#47vhafdal wants to merge 1 commit into
vhafdal wants to merge 1 commit into
Conversation
…options
Adds a v4.0 draft proposing four extensions contributed by the .NET community
implementation (toon-format/DevOp.Toon):
- §9.3.2: Mixed Columnar Arrays — new encoding form for object arrays with
both primitive and complex fields; primitive fields form a columnar header,
complex fields follow as per-row spill lines at depth +2.
- §13.5: objectArrayLayout encoder option ("auto" | "columnar")
- §13.6: ignoreNullOrEmpty encoder option (bool, default true) — suppress
all-null/empty fields and columnar columns
- §13.7: excludeEmptyArrays encoder option (bool, default true) — suppress
zero-length array fields
- Appendix G.6: non-normative guidance for typed binary/byte array encoding
Includes 24 new test fixtures (encode/object-array-layout.json,
encode/null-empty.json, encode/empty-arrays.json) and strict-mode error
entries for columnar row count/width mismatches.
BREAKING: v3.x strict-mode decoders will error on columnar-encoded output.
v4.0 decoders MUST detect and decode both §9.3 tabular and §9.3.2 columnar
forms.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
|
Regarding these improvments in the protcol And enabled support for Toon in api Updated a production system to move from json to toon So the customizations suggested I think will help Toon to evolve and possibly be a contender to Json ;) |
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.
Summary
This draft PR proposes four new features for TOON v4.0, contributed from a community implementation. The changes are submitted as an RFC for community review before any merge decision.
Proposed Changes
§9.3.2 — Mixed Columnar Arrays (BREAKING)
A new encoding form for object arrays that contain both primitive and complex fields. Primitive fields are extracted into a columnar header; complex fields follow each row as spill lines at depth +2.
Example (indent = 2):
```
[2]{id,name,score}:
1,Alice,9.5
tags[2]: a,b
address:
city: NY
2,Bob,7.0
tags[1]: c
address:
city: LA
```
Breaking impact: v3.x strict-mode decoders will error on this output. v4.0 decoders MUST detect and decode both §9.3 tabular and §9.3.2 columnar forms using the spill-line detection algorithm defined in the new section.
§13.5 —
objectArrayLayoutencoder option"auto"(default): preserves existing v3.x tabular detection"columnar": activates mixed columnar encoding (§9.3.2)§13.6 —
ignoreNullOrEmptyencoder option (boolean, defaulttrue)Omit object fields whose value is
nullor"". In columnar arrays, suppress entire columns where all rows are null/empty. Lossy — implementations must document.§13.7 —
excludeEmptyArraysencoder option (boolean, defaulttrue)Omit array-valued fields when the array length is 0. Lossy — implementations must document.
Appendix G.6 — Binary/byte array guidance (non-normative)
Recommendation for typed implementations encoding binary data: Base64 string (default) or numeric array. Both are valid TOON.
Test Fixtures
24 new test fixtures across three files:
tests/fixtures/encode/object-array-layout.json— 9 columnar encoding teststests/fixtures/encode/null-empty.json— 8 ignoreNullOrEmpty teststests/fixtures/encode/empty-arrays.json— 7 excludeEmptyArrays testsVersioning
Per VERSIONING.md: the columnar layout introduces new required decoder behavior → MAJOR bump (v4.0). The three encoder options produce valid v3.x output and would qualify as MINOR in isolation, but are bundled here since they interact with the columnar feature.
Open Questions for Community Review
objectArrayLayout="auto"also decode columnar documents, or should decoding require an explicit option?ignoreNullOrEmptyandexcludeEmptyArraysalso be available as standalone v3.1 additions for non-columnar use cases?ignoreNullOrEmptyandexcludeEmptyArraysbefalseto preserve round-trip fidelity by default?🤖 Generated with Claude Code