select an entry
jq '.jwt'
This will select and print the jwt value from a json object. The -r
option is
helpful here sometimes as it will print the "raw" value without qoutes or
anything.
select multiple fields from an array of objects
jq '.[] | .login, .id'
delete an entry from an array
$ echo '{"hello": "world", "myarray": ["a", "b", "c"]}' | jq
{
"hello": "world",
"myarray": [
"a",
"b",
"c"
]
}
To remove an element from the array, use the del function with the select
function to select a single element:
jq 'del(.myarray[] | select(. == "b"))'
remove quotes from the results
-r or --raw-output