jq¶
Overview¶
jq is a lightweight and flexible command-line JSON processor. Doc
jq is like sed for JSON data - you can use it to slice and filter and map and transform structured data with the same ease that sed, awk, grep and friends let you play with text.
Usage¶
ID_TOKEN=$(curl -0 -X POST https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/SERVICE_ACCOUNT:generateIdToken \
-H "Content-Type: text/json; charset=utf-8" \
-H "Authorization: Bearer $STS_TOKEN" \
-d @- <<EOF | jq -r .token
{
"audience": "SERVICE_URL"
}
EOF)
echo $ID_TOKEN
Example 2:
# Previous response
echo '${{ env.SLACK_PRE_RELEASE_RESPONSE }}' > slack.json
# Get trace ID
declare TRACE_ID=$(cat slack.json | jq '.trace_id')
# Get related parent
# follow: https://api.slack.com/methods/chat.postMessage#examples
declare PARENT_CHANNEL=$(cat slack.json | jq '.response.channel')
declare PARENT_THREAD_ID=$(cat slack.json | jq '.response.ts')