25 #require_once 'Zend/Json.php'; 101 $this->_sourceLength = strlen($this->_source);
110 $this->_decodeType = $decodeType;
147 #require_once 'Zend/Json/Exception.php'; 150 #require_once 'Zend/Json/Exception.php'; 154 $decoder =
new self(
$source, $objectDecodeType);
156 return $decoder->_decodeValue();
167 switch ($this->_token) {
204 while ($tok && $tok != self::RBRACE) {
205 if ($tok != self::DATUM || ! is_string($this->_tokenValue)) {
206 #require_once 'Zend/Json/Exception.php'; 210 $key = $this->_tokenValue;
213 if ($tok != self::COLON) {
214 #require_once 'Zend/Json/Exception.php'; 222 if ($tok == self::RBRACE) {
226 if ($tok != self::COMMA) {
227 #require_once 'Zend/Json/Exception.php'; 234 switch ($this->_decodeType) {
238 foreach ($members as $key =>
$value) {
267 while ($tok && $tok != self::RBRACKET) {
272 if ($tok == self::RBRACKET || !$tok) {
276 if ($tok != self::COMMA) {
277 #require_once 'Zend/Json/Exception.php'; 295 '/([\t\b\f\n\r ])*/s',
300 && $matches[0][1] == $this->_offset)
302 $this->_offset += strlen($matches[0][0]);
315 $this->_tokenValue =
null;
318 if ($this->_offset >= $this->_sourceLength) {
350 if (
$i >= $str_length) {
358 if (
$i >= $str_length) {
391 #require_once 'Zend/Json/Exception.php'; 393 .
"sequence '" . $chr .
"'");
400 }
while (
$i < $str_length);
407 if ((
$i+ 3) < $str_length && substr($str,
$start, 4) ==
"true") {
410 $this->_tokenValue =
true;
414 if ((
$i+ 4) < $str_length && substr($str,
$start, 5) ==
"false") {
417 $this->_tokenValue =
false;
421 if ((
$i+ 3) < $str_length && substr($str,
$start, 4) ==
"null") {
424 $this->_tokenValue = NULL;
429 if ($this->_token != self::EOF) {
430 $this->_offset =
$i + 1;
431 return($this->_token);
435 if ($chr ==
'-' || $chr ==
'.' || ($chr >=
'0' && $chr <=
'9')) {
436 if (preg_match(
'/-?([0-9])*(\.[0-9]*)?((e|E)((-|\+)?)[0-9]+)?/s',
437 $str, $matches, PREG_OFFSET_CAPTURE,
$start) && $matches[0][1] ==
$start) {
439 $datum = $matches[0][0];
441 if (is_numeric($datum)) {
442 if (preg_match(
'/^0\d+$/', $datum)) {
443 #require_once 'Zend/Json/Exception.php'; 446 $val = intval($datum);
447 $fVal = floatval($datum);
448 $this->_tokenValue = ($val == $fVal ? $val : $fVal);
451 #require_once 'Zend/Json/Exception.php'; 456 $this->_offset =
$start + strlen($datum);
459 #require_once 'Zend/Json/Exception.php'; 463 return($this->_token);
479 $delim = substr($chrs, 0, 1);
481 $strlen_chrs = strlen($chrs);
483 for(
$i = 0;
$i < $strlen_chrs;
$i++) {
485 $substr_chrs_c_2 = substr($chrs,
$i, 2);
486 $ord_chrs_c = ord($chrs[
$i]);
489 case preg_match(
'/\\\u[0-9A-F]{4}/i', substr($chrs,
$i, 6)):
491 $utf16 = chr(hexdec(substr($chrs, (
$i + 2), 2)))
492 . chr(hexdec(substr($chrs, (
$i + 4), 2)));
496 case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
499 case ($ord_chrs_c & 0xE0) == 0xC0:
502 $utf8 .= substr($chrs,
$i, 2);
505 case ($ord_chrs_c & 0xF0) == 0xE0:
508 $utf8 .= substr($chrs,
$i, 3);
511 case ($ord_chrs_c & 0xF8) == 0xF0:
514 $utf8 .= substr($chrs,
$i, 4);
517 case ($ord_chrs_c & 0xFC) == 0xF8:
520 $utf8 .= substr($chrs,
$i, 5);
523 case ($ord_chrs_c & 0xFE) == 0xFC:
526 $utf8 .= substr($chrs,
$i, 6);
552 return mb_convert_encoding($utf16,
'UTF-8',
'UTF-16');
555 $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
558 case ((0x7F & $bytes) == $bytes):
561 return chr(0x7F & $bytes);
563 case (0x07FF & $bytes) == $bytes:
566 return chr(0xC0 | (($bytes >> 6) & 0x1F))
567 . chr(0x80 | ($bytes & 0x3F));
569 case (0xFFFF & $bytes) == $bytes:
572 return chr(0xE0 | (($bytes >> 12) & 0x0F))
573 . chr(0x80 | (($bytes >> 6) & 0x3F))
574 . chr(0x80 | ($bytes & 0x3F));
elseif(isset( $params[ 'redirect_parent']))
__construct($source, $decodeType)
static _utf162utf8($utf16)
static decodeUnicodeString($chrs)
static decode($source=null, $objectDecodeType=Zend_Json::TYPE_ARRAY)