title: Bash - Parse associative Array to JSON with k-v
body: <p>The example here:</p>
  <pre><code>#!/bin/bash
  
  declare -A rep_hostname
  rep_hostname=( [test1]='172.1.1.1' [test2]='172.1.1.2' [test3]='172.1.1.3' )
  
  json=$(
          jo members=&quot;$(
                  jo -a &quot;${rep_hostname[@]}&quot; |
                  jq -c 'to_entries | map({ &quot;_id&quot;: .key, &quot;host&quot;: .value })'
          )&quot;
  )
  
  echo &quot;$json&quot;
  </code></pre>
  <p>outputs the following:</p>
  <pre><code>{
      &quot;members&quot;:[
        {&quot;_id&quot;:0,&quot;host&quot;:&quot;172.1.1.3:2701&quot;},
        {&quot;_id&quot;:1,&quot;host&quot;:&quot;172.1.1.2:2701&quot;},
        {&quot;_id&quot;:2,&quot;host&quot;:&quot;172.1.1.1:2701&quot;}
      ]
  }
  </code></pre>
  <p>How to make the following JSON?</p>
  <pre><code>{
      &quot;test1&quot;:&quot;172.1.1&quot;,
      &quot;test2&quot;:&quot;172.1.1.2&quot;,
      &quot;test3&quot;:&quot;172.1.1.3&quot;
  }
  </code></pre>