【发布时间】:2015-11-17 06:07:40
【问题描述】:
我正在使用 Codeigniter 中的 json,并且我有一些输出空值的字段,我想将这些空值更改为空字符串。我不想一一检查每个字段。我的CI代码是这样的:
$result= $this->get_model->get_model();
header("content-type: application/json");
$data[] = array('name'=>"result",'data'=>$result);
echo json_encode(array('success'=> 1,'posts'=>$data));
return $result;
【问题讨论】:
-
一旦你转换成字符串。用空字符串替换
null -
你能用例子解释一下或者给我一个链接
-
你能告诉我
echo json_encode(array('success'=> 1,'posts'=>$data));这行打印什么输出吗? -
这是代码 sn-p : "name":"latest", "data":[ { "timestamp":"2015-11-16 11:34:03", "avg_rating" :null } ]
标签: php json codeigniter codeigniter-2