Skip to content

Conversation

rolandwalker
Copy link
Contributor

Description

Add two JSON-based output formats

  • jsonl: JSONlines format: in which each row is represented on a line as a JSON object, with the column names recapitulated on every line as the property names.
  • jsonl_escaped: like jsonl, except that JSON escaping is applied for non-ASCII characters.

Most users will want jsonl. The implementation file has the generic name json_output_adapter.py in case other JSONish forms are desired.

This output format can be combined with jq redirection in mycli:

Checklist

  • I've added this contribution to the CHANGELOG.
  • I've added my name to the AUTHORS file (or it's already there).
  • I installed pre-commit hooks (pip install pre-commit && pre-commit install), and ran black on my code.
  • Please squash merge this pull request (uncheck if you'd like us to merge as multiple commits)

@rolandwalker
Copy link
Contributor Author

I'm not sure what the preprocessors = (override_missing_value, bytes_to_string, convert_to_string) line does, but copied it from the TSV output adapter.

@rolandwalker rolandwalker force-pushed the RW/add-jsonl-output-formats branch from f95201d to 130ab1c Compare July 9, 2025 20:56
@rolandwalker rolandwalker self-assigned this Jul 9, 2025
@rolandwalker rolandwalker requested a review from amjith July 9, 2025 20:57
 * jsonl: JSONlines format: in which each row is represented on a line
   as a JSON object, with the column names recapitulated on every line
   as the property names.
 * jsonl_escaped: like jsonl, except that JSON escaping is applied for
   non-ASCII characters.

Most users will want jsonl.  The implementation file has the generic
name json_output_adapter.py in case other JSONish forms are desired.

This output format can be combined with jq redirection in mycli:

 * dbcli/mycli#1248
@rolandwalker rolandwalker force-pushed the RW/add-jsonl-output-formats branch from 130ab1c to d17b7b8 Compare July 10, 2025 14:58
@rolandwalker rolandwalker merged commit 87599be into main Jul 10, 2025
2 checks passed
@rolandwalker rolandwalker deleted the RW/add-jsonl-output-formats branch July 10, 2025 18:13
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.

2 participants