refactor(output)!: emit table rows as NDJSON records, keyed by json tags - #135
Merged
Ilyes512 merged 1 commit intoSep 4, 2026
Conversation
BREAKING CHANGE: `-o json` table output is one JSON object per line instead of one array, its keys are snake_case from the row type's json tags instead of the column headings, and each value keeps its own type. A pipeline reading `jq '.[].Name'` becomes `jq -r .name`. Table took [][]string, so the pretty renderer's display strings were the only thing the JSON writer ever saw. A count arrived as "12", a timestamp as whatever the table decided to render it as, and `jq 'select(.count > 5)'` could not work on any of it. The array it emitted could not be parsed until its closing bracket arrived, so a killed run left nothing readable — the property NDJSON exists to provide, and which the docs already claimed. And the column heading doubled as the JSON key, so one string was doing two jobs for two audiences: prose a reader may reword freely, and what a consumer's filter matches on. None of the three could be fixed alone. Giving the two audiences separate inputs answers the key-naming question by itself: a row type with json tags for the consumer, Column headers for the reader, and a generic Table deriving both from the same rows — which is also what now guarantees every row has exactly one cell per header. template list gains from the split immediately: it emits the timestamps themselves rather than the "3 days ago" the table shows, and omits a field it has no value for rather than the "-" placeholder. template update emits up_to_date beside the status sentence, so a consumer filters on the fact rather than on a phrase that may be reworded. Closes #109
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.
BREAKING CHANGE:
-o jsontable output is one JSON object per line instead ofone array, its keys are snake_case from the row type's json tags instead of the
column headings, and each value keeps its own type. A pipeline reading
jq '.[].Name'becomesjq -r .name.Table took [][]string, so the pretty renderer's display strings were the only
thing the JSON writer ever saw. A count arrived as "12", a timestamp as
whatever the table decided to render it as, and
jq 'select(.count > 5)'couldnot work on any of it. The array it emitted could not be parsed until its
closing bracket arrived, so a killed run left nothing readable — the property
NDJSON exists to provide, and which the docs already claimed. And the column
heading doubled as the JSON key, so one string was doing two jobs for two
audiences: prose a reader may reword freely, and what a consumer's filter
matches on.
None of the three could be fixed alone. Giving the two audiences separate
inputs answers the key-naming question by itself: a row type with json tags for
the consumer, Column headers for the reader, and a generic Table deriving both
from the same rows — which is also what now guarantees every row has exactly
one cell per header.
template list gains from the split immediately: it emits the timestamps
themselves rather than the "3 days ago" the table shows, and omits a field it
has no value for rather than the "-" placeholder. template update emits
up_to_date beside the status sentence, so a consumer filters on the fact
rather than on a phrase that may be reworded.
Closes #109
Stack created with GitHub Stacks CLI • Give Feedback 💬