I am doing a curl
call to a server from a bash
script. In the response I want to extract some data using jq
. but, I am getting below error from jq
jq: error (at <stdin>:1): Cannot index number with string "_links"
Part of script:
#!/bin/bash
set -e
keyword="config"
response=$(curl --location "${HEADERS[@]}" -s -w "%{http_code}\n" -X GET "$url")
if echo ${response} | grep "$keyword" ; then
extract=$(jq -r "._links" <<< "${response}")
echo "$extract"
fi
The actual response:
{
"config": {
"polling": {
"sleep": "00:20:00"
}
},
"_links": {
"deployment": {
"href": "https://www.example.com"
},
"configData": {
"href": "https://www.example.com/configData"
}
}
}
200
Can anyone please let me know what is the issue here?
Thanks in advance
P.S: I am testing on Ubuntu (on WSL). please let me know if any info is missing