title: How to pass json data to highcharts series?
body: <p>I have following json array which is generated at runtime.
  Hence the number of name/data pairs varies.</p>
  
  <pre><code>`var sales = { "SalesData" : [ 
  { "name"  : "AllProducts|Canada", "data" :[44936.0,50752.0] },
  { "name"  : "AllProducts|Mexico", "data" : [200679.0,226838.0] },
  { "name"  : "AllProducts|USA",    "data" : [288993.0,289126.0] }
                      ]}    `
  </code></pre>
  
  <p>I want to pass this data to series in highcharts.</p>
  
  <p>This is how I am doing it currently.</p>
  
  <pre><code>series: [     
          {name:sales.SalesData[0].name,data:sales.SalesData[0].data},
          {name:sales.SalesData[1].name,data:sales.SalesData[1].data},
          {name:sales.SalesData[2].name,data:sales.SalesData[2].data}
  
              ]
  </code></pre>
  
  <p><strong>But if the number of elements in array are changed then this won't  work.</strong>
  How do I solve this problem ? Demo code will help me.</p>
  
  <p>I have refereed following questions but I was not able to solve the problem.</p>
  
  <p><a href="https://stackoverflow.com/questions/11720558/dynamically-adding-to-highcharts">Dynamically adding to Highcharts</a></p>
  
  <p><a href="https://stackoverflow.com/questions/16061032/highcharts-series-data-array">Highcharts series data array</a></p>