Get php to output Json with out quotes so that javascript will see it as a object -
here problem having able output javascript object
{ id : "title", name : "title", field : "title", width : 200, cssclass : "cell-title", editor : slick.editors.text }
notice editor : slick.editors.text not in quotes of kind.
i can output this... can't seem php not put quotes around slick.editor.text
{"id":"title","name":"title","field":"title","width":200,"cssclass":"cell-title","editor":"slick.editors.text"}
here php code using output string.
public function creatcolumn($id, $name, $field, $width, $cssclass, $editor = null) { $obj = (object) array('id'=>$id, 'name'=>$name, 'field'=>$field, 'width'=>$width, 'cssclass'=> $cssclass, 'editor' => $editor); return json_encode($obj); }
is there way output php json object php doesn't quote string?
it's little hacky, do:
public function creatcolumn($id, $name, $field, $width, $cssclass, $editor = null) { $obj = (object) array('id'=>$id, 'name'=>$name, 'field'=>$field, 'width'=>$width, 'cssclass'=> $cssclass); $json = json_encode($obj); return str_replace('}', '"editor":'.$editor.' }', $json); }
Comments
Post a Comment