Looking at the JSON data below:
[
{ 'Album': 'Dearest', 'Artist': 'Theresa Fu', 'Year': '2009'},
{ 'Album': 'To be Free', 'Artist': 'Arashi', 'Year': '2010'}
]
I am interested in re-ordering the attribute / value pairs using JavaScript on the client side. For example:
[
{ 'Album': 'Dearest', 'Year': '2009', 'Artist': 'Theresa Fu'},
{ 'Album': 'To be Free', 'Year': '2010' 'Artist': 'Arashi'}
]
Is there a straightforward way to achieve this? Or do I need to manipulate strings with JavaScript and then reconstruct the data (any code samples would be helpful). Just so you know, I will only be working with a small amount of data - around 5 attributes and 10-15 rows.
Why am I doing this, you might wonder? Well, my aim is to utilize a JQuery Table plug-in:
As far as I understand, the column order in the grid needs to match the order of attribute/value pairs in the JSON (I'll verify this)... but I want to display them in a different order than they are stored in the payload.
Update... I made a mistake. The plug-in does not require the columns to be in a specific order. I should have tested it before posting instead of assuming. My apologies.