Try the following;
function format(oldFormat) { var newFormat = []; oldFormat = oldFormat.data; for (var i=0;i<oldFormat.length;i++) { newFormat.push([oldFormat[i].id], oldFormat[i].name); }; return { aaData: newFormat }; } You'd then call use the function by;
var newStuff = format(varPointingToOldStuff); The function expects to receive a JavaScript object rather than JSON, and returns a JavaScript object rather than JSON. Make sure you understand the differences between a JSON (string) and a JavaScript objectMake sure you understand the differences between a JSON (string) and a JavaScript object.
You can convert a JSON string to a JavaScript object using JSON.parse(yourJsonString), and can convert a JavaScript object to a JSON string using JSON.stringify(yourJavaScriptObject).