我能够 使用: p>
类似地,我想实现 我无法遵循此解决方案:
带有JSON输入的CakePHP API PUT p>
我无法理解如何使用 p>
实现它。 p>
div>查看 code>和
删除 code>数据 在URl中传递ID的格式为: p>
/apis/view/id.json
code> pre>
公共功能视图($ id){
$ api = $ this-> Api-> findById($ id);
$ this-> set (array(
'api'=> $ api,
'_serialize'=> array('api')
));
}
code> pre>
add code>和
edit code>,我可以在HTTP体中以Json格式传递数据并在数据库中存储/编辑它。 p>
$ data = $ this - > request-> input('json_decode');
code> pre>
I am able to view
and delete
the data by passing ID in the URl in format of:
/apis/view/id.json
using:
public function view($id) {
$api = $this->Api->findById($id);
$this->set(array(
'api' => $api,
'_serialize' => array('api')
));
}
Similarly I want to implement add
and edit
, where I can pass data in Json format in the HTTP body and store/edit it in the database.
I couldn't follow the this solution: CakePHP API PUT with JSON input
I couldn't understand how to use
$data = $this->request->input('json_decode');
to achieve it.