Last active
September 26, 2020 19:42
-
-
Save goofrider/e6fb8c366e799230ed79c8ab646bff7b to your computer and use it in GitHub Desktop.
[jq cheatsheet] Basic jq usage #jq #json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### jq: sort by key value | |
jq '. | sort_by(.name)' | |
# Input | |
# [{name: "casey","age":54}, {"name": "Mary", "age":31}, {"name": "John", "age":20}] | |
# Output: | |
# [{"name": "John", "age": 20}, {"name": "Mary", "age":31}.{"name": "casey", "age":54}] | |
#### jq: filter by key value | |
jq ' .[] | select (.paid == "yes")' | |
# Input | |
# [{"name": "casey", "paid": "no"}, {"name": "Mary", "paid": "yes"}, {"name": "John", "paid": "no"}] | |
# Output: | |
# {"name": "Mary", "paid": "yes"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment