My goal is to transform a JSON array like this:
[Alex, James, John]
Into separate JSON arrays for each element, like this:
[[Alex], [James], [John]]
This will allow me to smoothly insert the JSON payload into a datatable using Datatables.JS.
I have made some progress with this code snippet:
var data = json;
while (data.length) {
console.log(data.splice(0, 1));
}
return data;
While this successfully splits the JSON into individual arrays, when I attempt to use the 'data' variable in Datatables.JS, it fails due to the format being:
[Alex]
[James]
[John]
To resolve this issue, I aim to combine them into the desired JSON payload structure mentioned earlier before inserting it into the datatable.