2009年2月21日星期六

Re: [fw-mvc] Zend JSON encoder / decode bug with line breaks (encoder won't convert to "\n")

-- Zladivliba Voskuy <nospampam@hotmail.fr> wrote
(on Saturday, 21 February 2009, 01:09 PM +0100):
> I'd like to confirm a bug before posting it.
>
> I'm using this function to send back Json data :
>
> public function sendJson($data)
> {
> $this->_helper->viewRenderer->setNoRender();
> $this->getResponse()->setHeader('content-type', 'application/
> json');
> echo Zend_Json::encode($data);
> }
>
> However when I'm using a line break, the encoder fails to convert it to "\n" as
> it should normally.
>
> Is this normal ?

I've often sent back JSON payloads with line breaks without issue. To
narrow this issue down, is ext/json installed and enabled on your
server? (phpinfo will tell you this) That way we'll know if it's an
issue with ext/json or Zend_Json_Encoder. If ext/json is enabled, what
version of PHP are you using?

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

没有评论: