I looked at similar questions before, but does not exactly answer my issue.
I'm using cURL to send a JSON request, like this:
curl -X POST -H "Content-Type:application/json" "$HOST" -d '{"uri": "'"$URI"'", "identityKeyValue":"'"`date +%s`"'", "identityKeyType": "bar", "status": "'$STATUS'", "statusDetail": "'"$STATUS_DETAIL"'", "exclusionKeys": [], "monitoredEntity": {"name": "foobar"}, "timestamp":'"`date +%s`"', "metadata": {} }'
It works, but it is very ugly (I'm talking about the part after -d
), but I couldn't find something better meeting the following:
- Supports variable substitution (like
$STATUS
) - Support command substitution (like
`date +%s`
)
Since it's JSON, it obviously needs a lot of doublequotes ("
)
The command does not have to be one line. I want readability & clarity rather than this messy/hacky look. What do you suggest?