I want to transform a JSON formatted output to another.
How I can do this?
Example:
Old JSON
"data":
[
{
"id" : "e49e183e-9325-4e62-8eda-7e63fb7cdbbd",
"name" : "test"
},
{
"id" : "ac310894-d808-447b-a189-d07edb7f6dd7",
"name" : "test2"
}
]
New JSON which I want without braces only like this with bracket
"aaData":
[
[
"e49e183e-9325-4e62-8eda-7e63fb7cdbbd","test"
],
[
"ac310894-d808-447b-a189-d07edb7f6dd7","test2"
]
]
You could just loop through the items and push them into a new object:
example: https://jsfiddle.net/q2Jzb/1/
You are presumably passing these to DataTables (as you use the name aaData), note that DataTables takes an object as the configuration, it’s not the same as JSON.