Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indent JSON when stdout is terminal #12555

Open
1 of 2 tasks
roberth opened this issue Feb 24, 2025 · 0 comments
Open
1 of 2 tasks

Indent JSON when stdout is terminal #12555

roberth opened this issue Feb 24, 2025 · 0 comments
Labels
feature Feature request or proposal idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome.

Comments

@roberth
Copy link
Member

roberth commented Feb 24, 2025

Is your feature request related to a problem?

Single-line JSON is hard to read, because the nesting structure is not visible.

Proposed solution

Format the JSON output by indenting it when the stdout is a terminal.

Considerations:

  • Indentation can be O(n²) behavior
    • Usually not
    • User can interrupt
  • JSON is for machines
    • Not when the output is a terminal

Alternative solutions

--json --indent

Defeats the utility of not having to specify that in the terminal.

Additional context

Checklist


Add 👍 to issues you find important.

@roberth roberth added feature Feature request or proposal idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. labels Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request or proposal idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome.
Projects
None yet
Development

No branches or pull requests

1 participant