【发布时间】:2013-12-22 13:02:20
【问题描述】:
如何将数组定义为模型类中的属性?
让我总结一下我做了什么......
我的模型类包含一个数组
class Author {
/**
* @var string {@from body}
* name of the Author {@required true}
*/
public $name = 'Name';
/**
* @var string {@type email} {@from body}
* email id of the Author
*/
public $email = 'name@domain.com';
/**
* @var array $arr {@type array} array of person
* {@required true}
*/
public $arr = array();
}
我测试 throw restler 的功能是:
/**
* POST
* post Author
*
* @param {@type Author} $a
*
* @return Author
*/
function postAuthor(Author $a) {
return $a;
}
当我尝试远程测试和类函数时抛出 index.html 它作为值返回:
{
"name":"",
"email":"",
"arr":""
}
我需要按如下方式返回:
{
"name":"",
"email":"",
"arr":[]
}
我该怎么做才能做到这一点?
【问题讨论】: