I'm struggling with generating a table in Angular2 from JSON data because I need to pivot the information, but my usual method doesn't seem to work for this scenario.
Below is an excerpt of the JSON data I am working with:
[
{
"ValueDate": "2017-04-26T14:16:00",
"AccountName": "CASHAUD",
"Holding": 318622.53
},
...
]
I attempted following a tutorial on converting columns to rows using JavaScript to pivot the JSON array. The result was an array of arrays as shown below:
The outcome wasn't bad; however, the headings are consistently located at [i][0]
and the data can be found at [i + 1][j]
.
Does anyone have suggestions on how I could iterate through these arrays to generate either an object or another array that I can use to build a table?