'Change the columns of a jquery datatable based on the inbound data

I have a data source something like this. The number of amount entries are consistent, but
sometimes there may be three+ months of data instead of two.

How do I add extra columns to the jquery DataTable based on examining the inbound data?

{
    "data": [
        {
            "name": "fred",
            "amount": [
                {
                    "month": "January",
                    "fee": 10
                },
                {
                    "month": "February",
                    "fee": 18
                }
            ]
        },
        {
            "name": "dusty",
            "amount": [
                {
                    "month": "January",
                    "fee": 10
                },
                {
                    "month": "February",
                    "fee": 20
                }
            ]
        }
    ]
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source