I want to generate a csv from array of Json data which I have below .
var keyDistribution =  [
                         [
                            {
                               "port": 4444,
                                "ipAddress": "52.35.15.121",
                                  "noOfKeys": 1
                                 },
                                 {
                                   "port": 2222,
                                   "ipAddress": "52.35.15.121",
                                   "noOfKeys": 1
                                 },
                                 {
                                   "port": 3333,
                                   "ipAddress": "52.35.15.121",
                                   "noOfKeys": 0
                                 }
                               ]
                             ];
How can I achieve this ?
I know how to generate a CSV from array as belows :
var data = [["name1", "city1", "some other info"], ["name2", "city2", "more info"]];
        var csvContent = "data:text/csv;charset=utf-8,";
        keyDistribution.forEach(function(infoArray, index){
           dataString = infoArray.join(",");
           csvContent += index < data.length ? dataString+ "\n" : dataString;
        }); 
        var encodedUri = encodeURI(csvContent);
        window.open(encodedUri);
        var encodedUri = encodeURI(csvContent);
        var link = document.createElement("a");
        link.setAttribute("href", encodedUri);
        link.setAttribute("download", "my_data.csv");
        link.click();
But can some one please help me out how can I generate this data from Array of Json data (keyDistribution variable)? 
I want the output in format :
[["port": 4444, "ipAddress": "52.35.15.121","noOfKeys": 1], ["port": 2222, "ipAddress": "52.35.15.121", "noOfKeys": 1]...];


forand collect the same data.