jq

A command-line JSON processor.

https://stedolan.github.io/jq/

Examples

“grep”ing from JSON.

Find all posts by “XXXX” from slack-exported JSON files. ag -l lists the files where “XXXX” occurs. xargs passes each of them to jq.

.[] produces the list of items in the data. select commands keeps the items based on the filtering criterion. . prints the item. .text can be used to print only the text field in each item.

 ag -l "XXXX" | xargs jq '.[] | select(.user_profile.real_name == "XXXX") | .'