How can I update a json file using jq in a loop as below ? json file need to have the .queryToken updated and .result array appended using json in curl response body
while true
do
curl -k --location 'https://api.../queryMore' \
--user "uname:pswd" \
--data "$(jq '.queryToken' Process.json)" |
jq '{
numberOfResults: .numberOfResults,
queryToken: .queryToken,
result: .result
}'
#update .queryToken in Process.json and append .result to .result in Process.json
#break if no .queryToken
done
The file and curl response are identical in structure as in example below
{
"@type": "QueryResult",
"queryToken": "<base64text>",
"result": [
...
]
}
.result? A string, an array, and object? Have you considered using a proper programming languages like perl/ruby/python instead of a shell?