Zend Framework
3.0
|
Encode PHP constructs to JSON. More...
Static Public Member Functions | |
static | encode ($value, $cycleCheck=false, array $options=[]) |
Use the JSON encoding scheme for the value specified. | |
static | encodeClass ($className, $package= '') |
Encodes the given $className into the class2 model of encoding PHP classes into JavaScript class2 classes. | |
static | encodeClasses (array $classNames, $package= '') |
Encode several classes at once. | |
static | encodeUnicodeString ($value) |
Encode Unicode Characters to ASCII syntax. | |
Protected Member Functions | |
__construct ($cycleCheck=false, array $options=[]) | |
encodeValue (&$value) | |
Encode a value to JSON. | |
encodeObject (&$value) | |
Encode an object to JSON by encoding each of the public properties. | |
wasVisited (&$value) | |
Determine if an object has been serialized already. | |
encodeArray ($array) | |
JSON encode an array value. | |
encodeAssociativeArray ($array) | |
Encode an associative array to JSON. | |
encodeDatum ($value) | |
JSON encode a scalar data type (string, number, boolean, null). | |
encodeString ($string) | |
JSON encode a string value by escaping characters as necessary. | |
Static Protected Member Functions | |
static | utf82utf16 ($utf8) |
Convert a string from one UTF-8 char to one UTF-16 char. | |
Protected Attributes | |
$cycleCheck | |
$options = [] | |
$visited = [] | |
Encode PHP constructs to JSON.
|
protected |
bool | $cycleCheck | Whether or not to check for recursion when encoding. |
array | $options | Additional options used during encoding. |
|
static |
Use the JSON encoding scheme for the value specified.
mixed | $value | The value to be encoded. |
bool | $cycleCheck | Whether or not to check for possible object recursion when encoding. |
array | $options | Additional options used during encoding. |
|
protected |
JSON encode an array value.
Recursively encodes each value of an array and returns a JSON encoded array string.
Arrays are defined as integer-indexed arrays starting at index 0, where the last index is (count($array) -1); any deviation from that is considered an associative array, and will be passed to encodeAssociativeArray().
$array | array |
|
protected |
Encode an associative array to JSON.
JSON does not have a concept of associative arrays; as such, we encode them to objects.
array | $array | Array to encode. |
|
static |
Encodes the given $className into the class2 model of encoding PHP classes into JavaScript class2 classes.
NOTE: Currently only public methods and variables are proxied onto the client machine
$className | string The name of the class, the class must be instantiable using a null constructor. |
$package | string Optional package name appended to JavaScript proxy class name. |
InvalidArgumentException |
|
static |
Encode several classes at once.
Returns JSON encoded classes, using encodeClass().
string[] | $classNames | |
string | $package |
|
protected |
JSON encode a scalar data type (string, number, boolean, null).
If value type is not a string, number, boolean, or null, the string 'null' is returned.
mixed | $value |
|
protected |
Encode an object to JSON by encoding each of the public properties.
A special property is added to the JSON object called '__className' that contains the classname of $value; this can be used by consumers of the resulting JSON to cast to the specific class.
$value | object |
RecursionException | If recursive checks are enabled and the object has been serialized previously. |
|
protected |
JSON encode a string value by escaping characters as necessary.
string | $string |
|
static |
Encode Unicode Characters to ASCII syntax.
This algorithm was originally developed for the Solar Framework by Paul M. Jones.
https://github.com/solarphp/core/blob/master/Solar/Json.php string $value string
|
protected |
Encode a value to JSON.
Recursive method which determines the type of value to be encoded and then dispatches to the appropriate method.
$values are either
$value | mixed The value to be encoded. |
|
staticprotected |
Convert a string from one UTF-8 char to one UTF-16 char.
Normally should be handled by mb_convert_encoding, but provides a slower PHP-only method for installations that lack the multibyte string extension.
This method is from the Solar Framework by Paul M. Jones.
|
protected |
Determine if an object has been serialized already.
mixed | $value |
|
protected |
|
protected |
|
protected |