api-platform/api-platform#845 (comment)
Just to let you know: it seems the easiest way was to reorder the JSON response on the client side, using the dataFilter setting in jQuery.ajax():
$('#mytable').DataTable({
'serverSide': true,
'ajax': {
'url': '/api/my_api',
'headers': { 'Accept': "application/ld+json" },
'dataFilter' : function (data) {
var json = JSON.parse(data);
json.recordTotal = json['hydra:totalItems'];
json.recordsFiltered = json['hydra:totalItems'];
json.data = json['hydra:member'];
return JSON.stringify(json);
}
}
);
This means converting the JSON back to an object and then to a string again, though, but it works.