That did the trick, thank you!
To help others, this code takes a simple API which gives four nicely-formatted numbers on separate lines, and makes them available as variables.
# fetch contents of URL and save them to variable "count"
count="$( curl -fsSL https://www.example.com/api )"
a=("${(f)count}")
# output to next action
echo -en '{
"alfredworkflow" : {
"arg" : "egg",
"config" : {
},
"variables" : {
"subscribers" : "'
echo -e $a[1]'"'
echo -n ',
"views" : "'
echo -e $a[3]'"'
echo -n ',
"downloads" : "'
echo -e $a[2]'"'
echo -n ',
"pbjsubscribers" : "'
echo -e $a[4]'"'
echo -n '
}
}
}'
... I'm sure there's a nicer way of doing the above, but it works for me!
They're then available to the next building block (copy-to-clipboard and paste) as {var:subscribers} as one example.