Let’s talk about jq
, the command line JSON processor.
jq
works the UNIX way, and can use it the same way you use sed
, grep
and the likes.
It is very flexible and supports a lot of options, be sure to check it’s documentation.
Here are 2 simple examples to give you an idea:
1. Piping JSON to jq
:
.
denotes the root of the JSON, here we return the first element of the root array
... | jq '.[0]'
2. Filtering keys:
Only keep some keys id
, message.author
:
... | jq '.[0] | {id, message.author}'