I have script
#!/bin/bash
ARR=("a" "b")
collection_init_msg=$( jq -n --arg arr $ARR '{arr: [$arr]}')
echo some command "$collection_init_msg"
that should convert the ARR and print it as a JSON array.
Current result
some command { "arr": [ "a" ] }
What I want is:
some command { "arr": [ "a", "b" ] }
$ARRis exactly the same as${ARR[0]}. You can't pass the entire array as a single value; you can only pass a single string built from the elements of the array.