When using jq
to process JSON, I often lose the overview due to long JSON objects. Thus, something like jq . | less
would be nice. However, although the above works, the nice coloring by jq
is gone.
Is there another way to read jq
's output line by line, or window by window, without having the terminal spammed with the full JSON object?
Edit: This did not work for me: echo '{"hello": "world"}' | jq . | less -C
jq usually outputs non-ASCII Unicode codepoints as UTF-8, even if the input specified them as escape sequences (like "\u03bc"). Using this option, you can force jq to produce pure ASCII output with every non-ASCII character replaced with the equivalent escape sequence.
jp is a JSON processor for the command line using JSONPath (aka "a simpler jq, and with JSONPath").
jq is a free open source JSON processor that is flexible and straightforward to use. It allows users to display a JSON file using standard formatting, or to retrieve certain records or attribute-value pairs from it.
Use the jq -C (colorize) option, with more -r
or less -r
.
report.json is a file with JSON (cat report.json
prints but not formatted)
cat report.json | jq . -C | more
Outputs jq with pager and color
or via less instead of more
cat report.json | jq . -C | less -r
P.S: the comments in this question where also helpful so thanks for that
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With