rich-cli icon indicating copy to clipboard operation
rich-cli copied to clipboard

Support line-delimited JSON

Open dhirschfeld opened this issue 3 years ago • 2 comments

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.

dhirschfeld avatar Jun 20 '22 04:06 dhirschfeld

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

harkabeeparolus avatar Sep 12 '22 11:09 harkabeeparolus

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.

dhirschfeld avatar Sep 12 '22 11:09 dhirschfeld