Reputation: 21
function ()
{
for p in ${param} ;
do
curl -s -g GET '/api/query?param='[${p}] | jq '.'
done > results.json
}
each api query produces
{
"param": "1",
"size": "336",
"area": "600324.0035"
}
have a simple func in a bash script, which i need to generate a json list of all the iterated api query results in json format, for which i can run some other queries with jq, like sorting etc. but this is currently just outputting a bunch of these objects one after the other, without comma separation. silly solutions im trying to solve it within the func are causing other probs, like not sure how to deal with the problem of the final iteration with no comma. whats a better approach here? each result straight into a json array? post processing after the fact? or?
Upvotes: 0
Views: 39
Reputation: 116660
The function body should be s.t. like
for p in ${param} ;
do
curl -s -g GET '/api/query?param='[${p}]
done | jq -s .
Upvotes: 1