Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes

Zend_Json_Encoder Class Reference

Static Public Member Functions

static encode ($value, $cycleCheck=false, $options=array())
static encodeClass ($className, $package= '')
static encodeClasses (array $classNames, $package= '')
static encodeUnicodeString ($value)

Protected Member Functions

 __construct ($cycleCheck=false, $options=array())
 _encodeValue (&$value)
 _encodeObject (&$value)
 _wasVisited (&$value)
 _encodeArray (&$array)
 _encodeDatum (&$value)
 _encodeString (&$string)

Static Protected Member Functions

static _utf82utf16 ($utf8)

Protected Attributes

 $_cycleCheck
 $_options = array()
 $_visited = array()

Detailed Description

Definition at line 30 of file Encoder.php.


Constructor & Destructor Documentation

__construct ( cycleCheck = false,
options = array() 
) [protected]

Constructor

Parameters:
boolean$cycleCheckWhether or not to check for recursion when encoding
array$optionsAdditional options used during encoding
Returns:
void

Definition at line 60 of file Encoder.php.


Member Function Documentation

_encodeArray ( &$  array ) [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 encoded as such.

Parameters:
$arrayarray
Returns:
string

Definition at line 188 of file Encoder.php.

_encodeDatum ( &$  value ) [protected]

JSON encode a basic data type (string, number, boolean, null)

If value type is not a string, number, boolean, or null, the string 'null' is returned.

Parameters:
$valuemixed
Returns:
string

Definition at line 228 of file Encoder.php.

_encodeObject ( &$  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 name of the class of $value. This is used to decode the object on the client into a specific class.

Parameters:
$valueobject
Returns:
string
Exceptions:
Zend_Json_ExceptionIf recursive checks are enabled and the object has been serialized previously

Definition at line 115 of file Encoder.php.

_encodeString ( &$  string ) [protected]

JSON encode a string value by escaping characters as necessary

Parameters:
$valuestring
Returns:
string

Definition at line 251 of file Encoder.php.

_encodeValue ( &$  value ) [protected]

Recursive driver which determines the type of value to be encoded and then dispatches to the appropriate method. $values are either

Parameters:
$valuemixed The value to be encoded
Returns:
string Encoded value

Definition at line 91 of file Encoder.php.

static _utf82utf16 ( utf8 ) [static, protected]

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 multibye string extension.

This method is from the Solar Framework by Paul M. Jones

string $utf8 UTF-8 character string UTF-16 character

Definition at line 541 of file Encoder.php.

_wasVisited ( &$  value ) [protected]

Determine if an object has been serialized already

Parameters:
mixed$value
Returns:
boolean

Definition at line 165 of file Encoder.php.

static encode ( value,
cycleCheck = false,
options = array() 
) [static]

Use the JSON encoding scheme for the value specified

Parameters:
mixed$valueThe value to be encoded
boolean$cycleCheckWhether or not to check for possible object recursion when encoding
array$optionsAdditional options used during encoding
Returns:
string The encoded value

Definition at line 74 of file Encoder.php.

static encodeClass ( className,
package = '' 
) [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

Parameters:
$classNamestring The name of the class, the class must be instantiable using a null constructor
$packagestring Optional package name appended to JavaScript proxy class name
Returns:
string The class2 (JavaScript) encoding of the class
Exceptions:
Zend_Json_Exception

Definition at line 401 of file Encoder.php.

static encodeClasses ( array $  classNames,
package = '' 
) [static]

Encode several classes at once

Returns JSON encoded classes, using encodeClass().

Parameters:
array$classNames
string$package
Returns:
string

Definition at line 425 of file Encoder.php.

static encodeUnicodeString ( value ) [static]

Encode Unicode Characters to ASCII syntax.

This algorithm was originally developed for the Solar Framework by Paul M. Jones

http://svn.solarphp.com/core/trunk/Solar/Json.php string $value string

Iterate over every character in the string, escaping with a slash or encoding to UTF-8 where necessary

Definition at line 446 of file Encoder.php.


The documentation for this class was generated from the following file: