Textualize / rich-cli

Rich-cli is a command line toolbox for fancy output in the terminal
https://www.textualize.io
MIT License
3.1k stars 77 forks source link

Support line-delimited JSON #59

Open dhirschfeld opened 2 years ago

dhirschfeld commented 2 years ago

I have a log file where each line is a JSON record. It would be handy to be able to use rich to pretty-print the log file to make it more easily human-parseable from the command line.

harkabeeparolus commented 2 years ago

Not all JSON tools can handle JSON Lines. I agree that this could be a nice feature to add!

As a workaround, you can convert the file from JSON Lines to a regular JSON array with jq, and then pipe it to rich: cat foo.jsonl | jq -s | rich --json -

Of course, if you already have jq installed, it will also pretty-print your JSON Lines data directly... 😊 jq < foo.jsonl

dhirschfeld commented 2 years ago

I think I didn't have jq installed so reached for what was available... and I wanted to try out rich-cli! :grinning:

In the intervening months I've gotten a lot more familiar with jq so would probably use that for the job. It might still be nice if it were supported by rich but probably not a very high priority.