How do I pass in bash variables into a jq --arg parameter?
All I can get to work is this:
FINAL_JSON= #some JSON
PAYLOAD=$(echo $FINAL_JSON | jq ' {
"attachments": .
} ')
What's bothering me is that echo $FINAL_JSON thing. I should be able to pass in variables in jq??
PAYLOAD=$(jq -n --arg attach "$FINAL_JSON" '{
"attachments":$attach
}')
But all that does is pass the JSON in as a string. Without quotes " around the $FINAL_JSON I get this error:
error: syntax error, unexpected $end
{1 compile error
echo-->echo "$FINAL_JSON"echothoFINAL_JSON=$(jq -n '[]')? It simply returns a literal[]. What means# add stuff to FINAL_JSON?<<<"$FINAL_JSON".