I'm new to jq and struggling to obtain a json value and use it in a bash IF statement.
{
"animal": "elephant",
"colour": "red"
}
VAR=$( jq '.animal' animal.json )
echo "$VAR"
if [[ "$VAR" == "elephant" ]]; then
echo "this is an elephant"
else
echo "failed"
fi
When I run the script the comparison fails
What can change to make the script work?