I have a PHP array looking like:
$columnDefs = array();
$column = new StdClass();
$column->target = array(0);
$column->orderable = false;
$column->searchable = false;
$column->render = 'function(id){
return \'<input type="checkbox" value="\' + id + \'" />\';
}';
$columnDefs[] = $coluna;
I want to encode it with some kind of JSON to use it in JavaScript. The result should look like this:
[
{
"target": [0],
"orderable": false,
"searchable": false,
"render": function(id){
return '<input type="checkbox" value="' + id + '" />';
}
}
]
The problem is the json_encode()
PHP function is quoting the "render" field.
Is there a way to avoid this?