使用ZF使Zend_Rest_Server返回JSON而不是XML [英] Make Zend_Rest_Server return JSON instead of XML using ZF

查看:123
本文介绍了使用ZF使Zend_Rest_Server返回JSON而不是XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Zend_Rest_Server可以返回Json吗? 如果没有,还有什么选择(其他的lib建议也可以)

Can Zend_Rest_Server return Json ? If not, what are the alternatives ( other lib suggestions are ok also)

推荐答案

Zend_Rest_Server输出XML,即使在文档中没有明确指定.

Zend_Rest_Server outputs XML, eventhough not clearly specified in the documentation.

还有其他选择:

由于Zend_Rest_RouteZend_Rest_Controller,您可以利用Zend Framework提供的整个MVC架构.
您将在此处找到完整的示例:
http://techchorus.net/create-restful-applications-using-zend-framework

You could leverage the whole MVC architecture given by Zend Framework, thanks to Zend_Rest_Route and Zend_Rest_Controller.
You will find a complete example here:
http://techchorus.net/create-restful-applications-using-zend-framework

同样,该示例显示纯字符串,但使用json_encodeZend_Json::encode应该返回json.

Again, the example displays plain string, but using json_encode, or Zend_Json::encode should return json.

最后,是使用ContextSwitch功能的完整(高级)示例:
http://www.chrisdanielson.com/2009/09/02/creating-a-php-rest-api-using-the-zend-framework/

And finally, a complete (advanced) example that use the ContextSwitch feature:
http://www.chrisdanielson.com/2009/09/02/creating-a-php-rest-api-using-the-zend-framework/

(如果您需要有关ContextSwitch Action Helper的更多信息,请参阅文档.)

(If you need more information on ContextSwitch Action Helper, please refer to the documentation.)

不幸的是,由于信誉有限,我无法给您提供更多链接,但是Google是您的朋友,使用了zend rest jsonzend controller rest json ...

Unfortunately, my limited reputation prevent me from giving you more links, but Google is your friend using some magic words such as zend rest json or zend controller rest json ...

这篇关于使用ZF使Zend_Rest_Server返回JSON而不是XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆