Json/Decoder.php
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Json
- Version
- $Id: Decoder.php 24799 2012-05-12 19:27:07Z adamlundrigan $
\Zend_Json_Decoder
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants

EOF
= 0
These are not for public consumption, they are just used internally to the class.
Properties
Methods


__construct(string $source, int $decodeType) : void
Constructor
Name | Type | Description |
---|---|---|
$source | string | String source to decode |
$decodeType | int | How objects should be decoded -- see {@link Zend_Json::TYPE_ARRAY} and {@link Zend_Json::TYPE_OBJECT} for valid values |


_decodeArray() : array
Decodes a JSON array format: [element, element2,.
..,elementN]
Type | Description |
---|---|
array |


_decodeObject() : array | \StdClass
Decodes an object of the form: { "attribute: value, "attribute2" : value,.
..}
If Zend_Json_Encoder was used to encode the original object then a special attribute called __className which specifies a class name that should wrap the data contained within the encoded source.
Decodes to either an array or StdClass object, based on the value of $_decodeType. If invalid $_decodeType present, returns as an array.
Type | Description |
---|---|
array | \StdClass |


_decodeValue() : mixed
Recursive driving rountine for supported toplevel tops
Type | Description |
---|---|
mixed |


_getNextToken() : int
Retrieves the next token from the source stream
Type | Description |
---|---|
int | Token constant value specified in class definition |


_utf162utf8(string $utf16) : string
Convert a string from one UTF-16 char to one UTF-8 char.
Normally should be handled by mb_convert_encoding, but provides a slower PHP-only method for installations that lack the multibye string extension.
This method is from the Solar Framework by Paul M. Jones
Name | Type | Description |
---|---|---|
$utf16 | string | UTF-16 character |
Type | Description |
---|---|
string | UTF-8 character |


decode(string $source = null, int $objectDecodeType = \Zend_Json::TYPE_ARRAY) : mixed
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 Zend_Json::TYPE_OBJECT to the $objectDecodeType parameter.
Throws a Zend_Json_Exception if the source string is null.
Name | Type | Description |
---|---|---|
$source | string | String to be decoded |
$objectDecodeType | int | How objects should be decoded; should be either or {@link Zend_Json::TYPE_ARRAY} or {@link Zend_Json::TYPE_OBJECT}; defaults to TYPE_ARRAY |
Type | Description |
---|---|
mixed |
Exception | Description |
---|---|
\Zend_Json_Exception |
- Access
- public
- Static