false, 'enableJsonExprFinder' => false, 'objectDecodeType' => Zend_Json::TYPE_ARRAY, ); /** * Serialize PHP value to JSON * * @param mixed $value * @param array $opts * @return string * @throws Zend_Serializer_Exception on JSON encoding exception */ public function serialize($value, array $opts = array()) { $opts = $opts + $this->_options; try { return Zend_Json::encode($value, $opts['cycleCheck'], $opts); } catch (Exception $e) { require_once 'Zend/Serializer/Exception.php'; throw new Zend_Serializer_Exception('Serialization failed', 0, $e); } } /** * Deserialize JSON to PHP value * * @param string $json * @param array $opts * @return mixed */ public function unserialize($json, array $opts = array()) { $opts = $opts + $this->_options; try { $ret = Zend_Json::decode($json, $opts['objectDecodeType']); } catch (Zend_Json_Exception $e) { require_once 'Zend/Serializer/Exception.php'; throw new Zend_Serializer_Exception('Invalid json data'); } catch (Exception $e) { require_once 'Zend/Serializer/Exception.php'; throw new Zend_Serializer_Exception('Unserialization failed by previous error', 0, $e); } return $ret; } }