I have to send a POST request to some service with jsonJSON payload, and it includes some user input. That input variable needs to be JsonJSON-encoded to prevent injection attacks.
Code example that sends requests and parses response jsonJSON to RESP variable:
RESP=`curl --connect-timeout "10" -s -H "Content-Type: application/json" \
-X POST -d '{ "Attribute": '"'$USERINPUT'" }',\
$ENDPOINT | $JQ -r '.key'`
howHow to sanitize, or jsonJSON encode $USERINPUT, $USERINPUT before creating jsonJSON payload?