title: Write bash variables into JSON template file
body: <p>I need, using bash script, create json file with some variables within.</p>
  
  <p>For this purposes, I have a bash file, who creates json template file using cat: </p>
  
  <pre><code>cat &lt;&lt;'EOF' &gt; template.json
  {
  "ip_range" : "$snmp_ip1", 
  "types" : [ "snmp" ],
  "description" : "$snmp_cred1",
  "snmp.version": "v2c",
  "snmp.port" : 161,
  "snmp.community" : "$snmp_cred1",
  "snmp.retries" : 3,
  "snmp.timeout" : 2
  }
  EOF
  </code></pre>
  
  <p>Unfortunately, cat does not expand variables into values.
  So, then I need to insert some variables into template using jq and create some new file with expanded variables. 
  I tried to use jq for this with following code:</p>
  
  <pre><code>jq \
  --arg snmp_ip1 "$snmp_ip" \
  --arg snmp_cred1 "$snmp_cred" \
  '.["snmp_ip1"]=$snmp_ip1 | .["snmp_cred"]=$snmp_cred1' \
  &lt;$DIR/template.json &gt;$DIR/cred.json
  </code></pre>
  
  <p>Unfortunatelly, it just inserts new strings with variables, but not expands variables in template:</p>
  
  <pre><code>{
  "snmp_cred": "fortinet/fortigate/1.3.6.1.4.1.12356.101.1.37000_fortigate3700d/10.82.112.21@public",
  "snmp_ip1": "10.82.112.21",
  "ip_range": "$snmp_ip1",
  "types": [
  "snmp"
  ],
  "description": "$snmp_cred1",
  "snmp.version": "v2c",
  "snmp.port": 161,
  "snmp.community": "snmp_cred1",
  "snmp.retries": 3,
  "snmp.timeout": 2
  }
  </code></pre>
  
  <p>Can you hint me, how to rewrite script (or, maybe use another approach) to create json files with this output:</p>
  
  <pre><code>{
  "ip_range": "10.82.112.21",
  "types": [ "snmp" ],
  "description": "fortinet/fortigate/1.3.6.1.4.1.12356.101.1.37000_fortigate3700d/10.82.112.21@public",
  "snmp.version": "v2c",
  "snmp.port": 161,
  "snmp.community": "fortinet/fortigate/1.3.6.1.4.1.12356.101.1.37000_fortigate3700d/10.82.112.21@public",
  "snmp.retries": 3,
  "snmp.timeout": 2
  }
  </code></pre>