title: Bitcoin: error parsing json in bashscript to send BTC using sendmany command
body: <p>I am simulating a bitcoin network on my machine for which I have written a bash script to simulate the transactions between the nodes. When I use the <code>sendmany</code> option of <code>bitcoin-cli</code> to send transactions I am getting an json parsing error reported by <code>bitcoin-cli</code>.</p>
  
  <p>Code:</p>
  
  <pre><code>#!/bin/bash
  MAX_NODES=2
  MY_PATH=/home/ubuntu/test
  CLIENT=/usr/local/bin/bitcoin-cli
  
  declare -a addr
  
  function fcomp() {
          /usr/bin/awk -v n1=$1 -v n2=$2 'BEGIN{ if (n1&gt;n2) exit 0; exit 1}'
  }
  
  json="'{"
  
  #get addresses to send
  for ((i = 1; i &lt;= MAX_NODES; i++));
  do
      addr[$i-1]="$($CLIENT -regtest -rpcport=$((16500 + $i)) -datadir=$MY_PATH/$i/ getnewaddress myaccount)"
      if [ "$i" -lt "$MAX_NODES" ]
      then
          json="$json\"${addr[$i-1]}\":0.00001, "
      else
          json="$json\"${addr[$i-1]}\":0.00001"
      fi
  done
  
  json="$json}'"
  echo $json
  
  #loop to send money to other nodes
  for ((i = 1; i &lt;= MAX_NODES; i++));
  do
          balance=`$CLIENT -regtest -rpcport=$((16500 + $i)) -datadir=$MY_PATH/$i/ getbalance`
          if fcomp $balance 0.002; then
                  $CLIENT -regtest -rpcport=$((16500 + $i)) -datadir=$MY_PATH/$i sendmany myaccount $json
      fi
  done
  </code></pre>
  
  <p>echo json output:</p>
  
  <pre><code>'{"mj2FrDhEomSzyQtRoGY78oVRPcQs5L5o95":0.00001, "mkxnkT3kx9dsFS8V3qYydpL1o5F5MfwCvM":0.00001}'
  </code></pre>
  
  <p>This gives me an error as:</p>
  
  <pre><code>error: Error parsing JSON:'{"mj2FrDhEomSzyQtRoGY78oVRPcQs5L5o95":0.00001,
  </code></pre>
  
  <p>I tried all possible combinations of quotes, double quotes and escape sequences but failed. If I copy paste the output of <code>echo $json</code> to a manual <code>bitcoin-cli sendmany</code> command it works perfectly fine.</p>