Hi, I am creating a workflow and I want to create a script filter with strings from a bash array. Given I have an array called $regions that contains 3 strings. I want to create 3 list items from that using jq.
echo $regions
france netherlands denmark
I tried this command but the output is obviously not compliant with Alfreds JSON format.
jq -n --arg inarr "${regions}" '{ items: [ $inarr | split("\n") ] }'
{
"items": [
[
"france",
"netherlands",
"denmark"
]
]
}
I need the JSON to look like that:
{"items": [
{
"uid": "france",
"title": "france",
"arg": "france",
"autocomplete": "france",
"icon": {
"path": "icons/france.png"
}
},
{
"uid": "netherlands",
"title": "netherlands",
"arg": "netherlands",
"autocomplete": "netherlands",
"icon": {
"path": "icons/netherlands.png"
}
},
{
"uid": "denmark",
"title": "denmark",
"arg": "denmark",
"autocomplete": "denmark",
"icon": {
"path": "icons/denmark.png"
}
},
]}
Any help would be much appreciated.