I am trying to add a field to the data
variable. Initially, it is
{ "objects": [] }
I want to add another field called objects_count
such that
{ "objects": [], "objects_count": 1 }
Here is what I have so far:
echo $data
data=$( $data | jq --argjson oc "$objects_count" '. + {objects_count: $oc}' )
echo $data
And its output:
{ "objects": [] }
./scripts.sh: line 42: {: command not found
{ "objects_count": 1 }
Why is it not appending the field, and creating a new object instead?