【发布时间】:2013-07-02 09:03:25
【问题描述】:
我正在开发 Cakephp 2.x ...我想用 json 中的 som 数据返回对我的 android 应用程序的响应 ..这是我的函数,我如何在我的 cakephp 网络中获得响应..
public function phone(){
$this->loadModel('User');
if ($this->request->isPost()){
$json = $this->request->data('json');
$data = json_decode($json, TRUE);
if($data){
//here i want to send response back to mobile app
}
}
我想在我的 json 响应中这样返回.. 我的意思是我想在 json 响应中发送变量名及其值
[Contact] => Array
(
[idContacts] => 1
[name] => asad
[mobileNo] => 03224999464
【问题讨论】:
-
为什么不使用文档中的 JsonView? book.cakephp.org/2.0/en/views/json-and-xml-views.html
-
@mark 不知道如何使用它们
-
那里描述得很好。抱歉,但是在看到您提出很多这样的问题后,您看起来确实不想阅读,而是希望通过其他提供您可以复制和粘贴的代码来完成您的工作。如果您在使用编写良好的文档时遇到问题,您可能需要在继续编程之前解决该问题,因为使用文档是编程的重要组成部分。
标签: android json cakephp cakephp-2.0 cakephp-2.1