Last active
May 2, 2017 17:18
-
-
Save MarkyMarkMcDonald/594bc7e4213fae8c9c0a011fcfca9027 to your computer and use it in GitHub Desktop.
jq filter out children values
This file contains 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
echo '{"logs": ["All the cars are really good"],"info": {"cars": [{"name": "another car","type": "big"},{"name": "my car","type": "small"},{"name":"sweet ride", "type":"small"}]}}' | jq '.info.cars |= map(select(.type == "small")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When you have data like:
And want to filter all the non-small cars without losing your logs:
you can use assignment + map + select: