我正在为 JSON 使用 Zend Framework 助手。我使用创建的方法 toArray() 从域实体返回数据数组。
有没有办法将格式从整洁更改为漂亮?
PHP
$data = array(
"success"=>true,
"user"=>array($user->toArray())
);
$this->_helper->json($data);
身体反应:
{"success":true,"user":[{"id":9,"displayName":"joey","firstName":"joe","lastName":"blow","email":"joeblow@yahoo.com","role":"user"}]}
到:
{
"success":true,
"user": [{
"id":9,
"displayName":"joey",
"firstName":"joe",
"lastName":"blow",
"email":"joeblow@yahoo.com",
"role":"user"
}]
}