I'm currently working on an export feature, but the data being received from the API is not in the correct sequence (the keys of the object are in an array). I need to rearrange the keys in the object so that they are in the desired order for a single row. The current data looks like this:
data = [
{
"key4":"value4",
"key1":"value1",
"key5":"value5",
"key3":"value3",
"key2":"value2"
},
{
"key4":"value4",
"key1":"value1",
"key5":"value5",
"key3":"value3",
"key2":"value2"
}
]
What I want as output is:
data =[ {
"key1":"value1",
"key2":"value2",
"key3":"value3",
"key4":"value4",
"key5":"value5"
},
{
"key1":"value1",
"key2":"value2",
"key3":"value3",
"key4":"value4",
"key5":"value5"
}
]