ZF-11826: Usage examples for Zend_Controller_Action_Helper_Json in manual are incorrect


Most of the {{Zend_Controller_Action_Helper_Json}} examples on this page are incorrect:…

+Pass-through options into {{Zend_Json}}+

$this->_helper->json($data, array('enableJsonExprFinder' => true));
Looking at the implementation of {{Zend_Controller_Action_Helper_Json::direct}}, the second argument ({{$sendnow}}) does not accept array:

public function direct($data, $sendNow = true, $keepLayouts = false)
    if ($sendNow) {
        return $this->sendJson($data, $keepLayouts);
    return $this->encodeJson($data, $keepLayouts);
The parameter {{$keepLayouts}} is the one which is passed through to {{Zend_Json}}, so the proper example would be:

$this->_helper->json($data, true, array('enableJsonExprFinder' => true));

+Shortcut array notation+

This usage (2nd argument as array of options) is completely unsupported:

$this->_helper->json($data, array('keepLayouts' => true));


Rewrote the manual page section for {{Zend_Controller_Action_Helper_Json}} to correct the above issues and add additional information about the available methods and their arguments. Patch is attached.


Fixed in trunk r24688 Merged to release-1.11 in r24689