Jq json file manipulation: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 24: | Line 24: | ||
getting specific data from a subkey | getting specific data from a subkey | ||
<pre> | <pre> | ||
jq '.[0].id' filename | |||
jq '.[].data.category.name' filename | sort -u | jq '.[].data.category.name' filename | sort -u | ||
</pre> | </pre> |
Revision as of 08:34, 27 October 2017
viewing the top level structure for all objects
jq '.[]|keys' filename
viewing the top level structure for the first object
jq '.[0]|keys' filename
viewing the top level structure for the third object
jq '.[2]|keys' filename
viewing the first key for the first object
jq '.[0] | keys | .[0] filename
selecting a specific item (from the top level)
jq '.[] | select(.id=bla)' filename
getting specific data from a subkey
jq '.[0].id' filename jq '.[].data.category.name' filename | sort -u
http://blog.librato.com/posts/jq-json