1function jsonArrayTo2D(arrayOfObjects){
2 let header = [],
3 AoA = [];
4 arrayOfObjects.forEach(obj => {
5 Object.keys(obj).forEach(key => header.includes(key) || header.push(key))
6 let thisRow = new Array(header.length);
7 header.forEach((col, i) => thisRow[i] = obj[col] || '')
8 AoA.push(thisRow);
9 })
10 AoA.unshift(header);
11 return AoA;
12}