How to convert a multi-key hash to single key hash in Ruby for Highcharts
<p>I have this data in Ruby, for creating a barchart using Highcharts.js which requires the data in a JSON format:</p>

<pre><code>data = {["January", "a"]=&gt;54, ["January", "b"]=&gt;13, ["January", "d"]=&gt;2, ["January", "c"]=&gt;1, 
        ["February", "a"]=&gt;27, ["February", "b"]=&gt;11, ["February", "c"]=&gt;4, ["March", "a"]=&gt;22, 
        ["March", "b"]=&gt;11, ["March", "d"]=&gt;2, ["March", "c"]=&gt;2, ["April", "a"]=&gt;32, 
        ["April", "b"]=&gt;12, ["April", "d"]=&gt;6, ["April", "c"]=&gt;2, ["May", "a"]=&gt;7, 
        ["May", "d"]=&gt;3, ["June", "a"]=&gt;5, ["July", "a"]=&gt;25, 
        ["August", "a"]=&gt;23, ["August", "d"]=&gt;3, ["August", "c"]=&gt;3, ["September", "a"]=&gt;6}
</code></pre>

<p>The data is stored in a variable and is not coming from a file.</p>

<p>I want to convert this into a json object to send it to Highcharts for charting. I need the data in the following format:</p>

<pre><code>category = ["January","February","March","April","May","June","July","August","September"]

series: [{
            name: 'a',
            data: [54, 27, 22, 32, 7, 5, 25, 23, 6]
        }, {
            name: 'b',
            data: [13, 11, 11, 12, 6, 0, 0, 0, 6]
        }, {
            name: 'c',
            data: [1, 4, 0, 2, 0, 0, 0, 3, 6]
        },
            {
            name: 'd',
            data: [2, 0, 0, 6, 3, 0, 0, 3, 6]
        }]
</code></pre>

<p>The data is missing for some months, and sometimes not in alphabetical order. </p>

<p>Is there an easy way in Ruby to unlist the original Hash, and then extract the information out of it while filling the missing values with 0, and getting the JSON output as required?</p>

<p>p.s. :Tried converting the data.to_json but highcharts doesnt accept it in raw form. Is there any other way to create a bar chart using this data in Highcharts?</p>