需要使以下代码动态化

I am generating a highchart using json that is created by PHP. Everything is working perfectly fine. However I can't figure out how do I make the series dynamic in the following code? :

$.getJSON("myFile.php", function(json) {
        options.xAxis.categories = json[0]['data'];
        options.series[0] = json[1];
        options.series[1] = json[2];
        chart = new Highcharts.Chart(options);
});

In the above code, there are only 2 series. However I do not know how many series will be present as they will change according to user request. Can someone please tell me how to make this part dynamic:

options.series[0] = json[1];
options.series[1] = json[2];

Thanks in advance :)

$.each(json, function( index, value ) {
     options.series[index-1] = value;

});

Be careful to start your json to 1 if you want series from 0 to n

Try this

$.getJSON("myFile.php", function(json) {
  options.xAxis.categories = json[0]['data'];
  for (var i = 0; i < options.series.length; i++) {
    options.series[i] = json[i + 1];
  }
  chart = new Highcharts.Chart(options);
});