title: Rename Object Key in an array using javascript
body: <p>In my angular application i am getting an Json Data like below.</p>
  
  <pre><code>[{"id":"5","name":"Immidiate"},
  {"id":"4","name":"30 days"},
  {"id":"3","name":"21 days"},
  {"id":"2","name":"14 days"},
  {"id":"1","name":"7 days"},
  {"id":"6","name":"Custom"}]
  </code></pre>
  
  <p>I need an output like below,</p>
  
  <pre><code>[{"Name":"5","Data":"Immidiate"},
  {"Name":"4","Data":"30 days"},
  {"Name":"3","Data":"21 days"},
  {"Name":"2","Data":"14 days"},
  {"Name":"1","Data":"7 days"},
  {"Name":"6","Data":"Custom"}]
  </code></pre>
  
  <p>Here is my code </p>
  
  <pre><code>$rootScope.DashboardData["Name"] =  widget.seriesname ;
  delete $rootScope.DashboardData[widget.seriesname];                
  $rootScope.DashboardData["data"] =  widget.dataname ;
  delete $rootScope.DashboardData[widget.seriesname];
  widget.chartSeries = $rootScope.DashboardData;
  </code></pre>
  
  <p>where widget.seriesname is "id" and widget.dataname is "name".</p>
  
  <p><strong>Problem</strong>: Key is not changed!</p>