I'm using a framework to configure the properties for Datatables. I'm using PHP and Twig. I'm building an array, containing all data (such as aaData and aoColumnDefs) and configuration (sorting, columns, etc.). The problem I'm facing is that json_encode($config) returns the JSON representation of a value, enclosed by quotes.
DataTables expects a non-quotes value, but this is what my script returns:
How can I fix this?
DataTables expects a non-quotes value, but this is what my script returns:
$('#example').dataTable({"aoColumnDefs":[{"sType":"numeric","sWidth":"100px","aTargets":[4,5]});My problem: 'aoColumnDefs' has to be enclosed by quotes, but 'sType' of 'sWidth' may not be enclosed by quotes.
How can I fix this?