Reformat JSON data : <p><strong>Problem</strong></p>

<p>I have the following example json data which is not formatted how I need it:</p>

<pre><code>"stations": {
    "st1": "station 1",
    "st2": "station 2",
    "st3": "Station 3",
}
</code></pre>

<p><strong>Question</strong></p>

<p>How can I reformat the data to be:</p>

<pre><code>"stations": [
  {
    "id": "st1",
    "name": "station 1",
  },
  {
    "id": "st2",
    "name": "station 2",
  },
  {
    "id": "st3",
    "name": "station 3",
  }
]
</code></pre>

<p><strong>Tried</strong></p>

<p>I tried to simply log the data to test first but am struggling how to actually even iterate between the key/value pairs as they are essentially strings</p>

<p>This is what i tried:</p>

<pre><code>$.get( '/js/ajax/tube-data.json', function( data ) {

    $.each(data.stations, function () {
        // I was expecting st1, st2, st3 to show in the console
        // but got first letter of each station 
        console.log(this[0]) 
    });

}).error(function() {console.log(arguments) });
</code></pre>

<p>Is there a better way to do this?</p>
