Have you ever used an online JSON viewer? Imagine being able to pretty print JSON from
the comfort of your terminal. For example, if I have a json file called foo.json
.
I can pretty print it using the command.
jq . foo.json
Also, I can check the keys of the json like this
jq keys foo.json
I can access subset of a json by accessing using the key. For example, if the content of foo.json was:
{
'level': 'warning',
'message': 'A warning is a warning about something',
}
I can access the message by just doing this.
jq .message foo.json
We have just scratched the surface here. Stay tuned for other ways to use jq in your workflow.