title: Combine duplicate hash keys in ruby
body: <p>I am attempting to take JSON like this:</p>
  
  <pre><code>{"myhostname"=&gt;
    {"client"=&gt;"exemplar", "tag"=&gt;"mytag"},
   "mysecondhost"=&gt;
    {"client"=&gt;"exemplar", "tag"=&gt;"mytag2"},
   "myhost2"=&gt;
    {"client"=&gt;"exemplar", "envtag"=&gt;"mytag2"}}
  </code></pre>
  
  <p>My goal is to output something like:</p>
  
  <p>mytag:myhostname<br>
  mytag2:mysecondhost, myhost2</p>
  
  <p>It'll need to be JSON at the end of the day, but I'm using pyjojo and that seems to do a good job of reformatting it.  I'm trying to get a list of hosts for each key.</p>
  
  <p>The hostnames are dynamic.  It's been easy to get an output of "tag:host" for each of these, but I'm having a hard time dealing with the situation where the tag is duplicated, and I need to return each host as a comma separated value.</p>
  
  <p>Thank you in advance.</p>