JQ - Json Parser
☰ Table of Content
Cheat sheet for simple usage.
simple.json
| |
Command
| Command | Usage |
|---|---|
jq '.' simple.json | Print pretty |
jq '.id' simple.json | Print value of id |
jq -r '.id' simple.json | Print value of id, without quote |
jq '.id, .active' simple.json | Print value of id and active |
jq '.name.last' simple.json | Print value of last in name |
jq '.address[0]' simple.json | Print first item of array address |
Wildcard Select
jq don’t have wildcard select as of v1.6. So following does not work:
| |
Workaround with select(|contains()) or select(|startswith()).
| |
John Siu
Update: 2022-05-12