Restructure Objects coming from Rest-Api

Take a look at this: https://jsfiddle.net/9j96jbxn/1/

Replace your data.forEach(function (element) {...} with a nested for loop. This should get you close to what you are looking for.