Example #1
0
 public static function decode($source = null, $objectDecodeType = Zend_Json::TYPE_ARRAY)
 {
     if (null === $source) {
         throw new Zend_Json_Exception('Must specify JSON encoded source for decoding');
     } elseif (!is_string($source)) {
         throw new Zend_Json_Exception('Can only decode JSON encoded strings');
     }
     $decoder = new self($source, $objectDecodeType);
     return $decoder->_decodeValue();
 }
Example #2
0
 /**
  * Decode a JSON source string
  *
  * Decodes a JSON encoded string. The value returned will be one of the
  * following:
  *        - integer
  *        - float
  *        - boolean
  *        - null
  *      - StdClass
  *      - array
  *         - array of one or more of the above types
  *
  * By default, decoded objects will be returned as associative arrays; to
  * return a StdClass object instead, pass {@link Zend_Json::TYPE_OBJECT} to
  * the $objectDecodeType parameter.
  *
  * @static
  * @access public
  * @param string $source String to be decoded
  * @param int $objectDecodeType How objects should be decoded; should be
  * either or {@link Zend_Json::TYPE_ARRAY} or
  * {@link Zend_Json::TYPE_OBJECT}; defaults to TYPE_ARRAY
  * @return mixed
  */
 public static function decode($source, $objectDecodeType = Json::TYPE_OBJECT)
 {
     $decoder = new self($source, $objectDecodeType);
     return $decoder->_decodeValue();
 }
Example #3
0
 /**
  * decode ubjson format
  * 
  * @param string $source
  * @param int $decodeType
  * @return mixed
  */
 public static function decode($source, $decodeType = self::TYPE_ARRAY, $throwException = true)
 {
     $ubjson = new self($source);
     $ubjson->setDecodeType($decodeType);
     $ubjson->_getNextToken();
     $ubjson->setThrowException($throwException);
     $ubjson->cleanLastErrorMessage();
     return $ubjson->_decodeValue();
 }