Skip to content

feat: add --json output flag#74

Merged
vmvarela merged 1 commit intomasterfrom
issue-44/json-output-format
Mar 20, 2026
Merged

feat: add --json output flag#74
vmvarela merged 1 commit intomasterfrom
issue-44/json-output-format

Conversation

@vmvarela
Copy link
Copy Markdown
Owner

Summary

Closes #44

  • Adds --json flag that emits query results as a JSON array of objects ([{"col": value, ...}, ...])
  • INTEGER/REAL columns are emitted as JSON numbers; NULL → null; TEXT → JSON string with RFC 8259 escaping
  • Empty result set emits []
  • --json is mutually exclusive with --delimiter, --tsv, and --header (exits 1 with a clear error message)
  • Adds integration tests 14–17 covering: basic JSON output, NULL values, empty result, and incompatibility check

Acceptance Criteria

  • --json flag outputs results as a JSON array of objects
  • Each row is an object with column names as keys
  • Numeric values are JSON numbers (not strings)
  • NULL values are represented as JSON null
  • Empty result set outputs []
  • --json is mutually exclusive with --delimiter / --tsv / --header

Emit query results as a JSON array of objects when --json is used.
- Each row becomes an object with column names as keys
- INTEGER/REAL columns emit JSON numbers; NULL → null; TEXT → string
- Empty result set emits []
- --json is mutually exclusive with --delimiter, --tsv, --header
- writeJsonString() handles RFC 8259 escaping (control chars, quotes)
- Integration tests 14-17 cover normal, null, empty, and incompatible cases
@github-actions github-actions bot added type:feature New functionality type:chore Maintenance, refactoring, tooling labels Mar 20, 2026
@vmvarela vmvarela merged commit e091276 into master Mar 20, 2026
5 of 6 checks passed
@vmvarela vmvarela deleted the issue-44/json-output-format branch March 20, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:chore Maintenance, refactoring, tooling type:feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON output format (--json)

1 participant