How to print jq output sequentially

When using jq to handle JSON, I often lose jq due to long JSON objects. So something like jq . | less jq . | less jq . | less would be nice. However, while the above works, the beautiful coloring on jq disappeared.

Is there any other way to read jq output line by line or window by window, without using a terminal with a full JSON object?

Edit: This did not work for me: echo '{"hello": "world"}' | jq . | less -C echo '{"hello": "world"}' | jq . | less -C

+5
source share
2 answers

Use the jq -C (colorize) option with more -r or less -r .

+8
source

report.json is a JSON file ( cat report.json prints but not formatted)

 cat report.json | jq . -C | more 

Print jq with pager and color

or through less, not more

 cat report.json | jq . -C | less -r 

PS: comments in this question, where also useful, thanks for that

+1
source

Source: https://habr.com/ru/post/1240801/


All Articles