title: How to restructure JSON in JavaScript?
body: <p>I have a JSON file that comes in a particular structure (see Sample A), but  I need it too be structured like Sample B.</p>
  
  <p>Is it possible to reorganise the data in JS? If so, how do you go about this?</p>
  
  <p>Sample A:</p>
  
  <pre><code>   var myData = [
        {
          "date": "01/01/2017",
          "here-value": "20",
          "here-color": "pink",
          "there-value": "24",
          "there-color": "red",
        },
        {
          "date": "02/01/2017",
          "here-value": "80",
          "here-color": "blue",
          "there-value": "54",
          "there-color": "red",
        },
      ] 
  </code></pre>
  
  <p>Sample B:</p>
  
  <pre><code>  var myData = [
  
      {
        "date": "01/01/2017",
        "here-value": "20",
        "here-color": "pink"
      },
      {
        "date": "01/01/2017",
        "there-value": "24",
        "there-color": "red"
      },
  
      {
        "date": "02/01/2017",
        "here-value": "80",
        "here-color": "blue"
      },
      {
        "date": "02/01/2017",
        "there-value": "54",
        "there-color": "red"
      }
  
  ]
  </code></pre>
  
  <p>The reason I'm seeking to restructure the data, is to create objects that will feed into a visualisation using D3. 
  The result will be similar to: <a href="http://jsfiddle.net/vw88/nzwLg96a/" rel="nofollow noreferrer">http://jsfiddle.net/vw88/nzwLg96a/</a> </p>