ZF-11854: Zend_Json::prettyPrint causes warning when empty array given
Description
When empty array is given to Zend_Json::prettyPrint, it causes two warnings:
Zend_Json::prettyPrint(array());
Output: {quote} Warning: preg_split() expects parameter 2 to be string, array given in /usr/share/php5/Zend-1.11.11/Json.php on line 373 Warning: Invalid argument supplied for foreach() in /usr/share/php5/Zend-1.11.11/Json.php on line 403 {quote}
The encode() works properly:
echo Zend_Json::encode(array());
Output: {quote} [] {quote}
Comments
Posted by Adam Lundrigan (adamlundrigan) on 2011-10-28T14:00:07.000+0000
This is not a valid usage of {{Zend_Json::prettyPrint}}. That function accepts only JSON-encoded strings. To work correctly, your first code sample would have to look like this:
Method signature for {{Zend_Json::prettyPrint}}: