3 homepage: https://stedolan.github.io/jq/
5 jq is a lightweight and flexible command-line JSON processor.
14 Use the `@beta` tag for pre-releases.
18 > `jq` is like `sed` for JSON data - you can use it to slice and filter and map
19 > and transform structured data with the same ease that `sed`, `awk`, `grep` and
20 > friends let you play with text.
22 All jq selectors begin with `.` - don't forget that!
24 Be sure to checkout the
25 [official tutorial](https://stedolan.github.io/jq/tutorial/) and
26 [jq manual](https://stedolan.github.io/jq/manual/) for more info.
28 You can also [try online](https://jqplay.org/).
30 ### How to select a single a property from an object
33 echo '{ "name": "foo" }' | jq '.name'
40 ### How to remove quotes from strings
42 The `-r` or `--raw-output` flag unwraps strings:
45 echo '{ "name": "foo" }' | jq -r '.name'
52 ### How to select a whole object
55 echo '{ "name": "foo" }' | jq '.'
64 ### How to select an element from an array
67 echo '[ { "name": "foo" } ]' | jq '.[0]'
76 ### How to select a single property from an array element
79 echo '[ { "name": "foo" } ]' | jq -r '.[0].name'
86 ### How to select some properties from multiple elements
89 echo '[ { "name": "foo" }, { "name": "bar" } ]' \
98 ### How transform or zip an array
100 Anything that doesn't start with a `.` is part of the transformation template.
102 Anything that collects starts with `.[]`.
104 Anything that transforms has a pipe and selector `| .whatever`.
106 Be sure to checkout the
107 [official tutorial](https://stedolan.github.io/jq/tutorial/) and
108 [jq manual](https://stedolan.github.io/jq/manual/) for more info.
111 echo '[ { "name": "foo", "age": 0 }, { "name": "bar", "age": 2 } ]' \
112 | jq '{ names: [.[] | .name], ages: [.[] | .age] }'