Class Zend_Json_Encoder

Description

Encode PHP constructs to JSON

  • copyright: Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
  • license: New BSD License

Located in /Json/Encoder.php (line 36)


	
			
Variable Summary
 boolean $_cycleCheck
 array $_visited
Method Summary
 static string encode (mixed $value, [boolean $cycleCheck = false])
 static string encodeClass ($className $className, [$package $package = ''])
 static string encodeClasses ( $classNames, [string $package = ''])
 void __construct ([boolean $cycleCheck = false])
 string _encodeArray ($array &$array)
 string _encodeDatum ($value &$value)
 string _encodeObject ($value &$value)
 string _encodeString ($value &$string)
 string _encodeValue ($value &$value)
 boolean _wasVisited ( &$value, mixed $value)
Variables
boolean $_cycleCheck (line 43)

Whether or not to check for possible cycling

  • access: protected
array $_visited = array() (line 50)

Array of visited objects; used to prevent cycling.

  • access: protected
Methods
static encode (line 70)

Use the JSON encoding scheme for the value specified

  • return: The encoded value
  • access: public
static string encode (mixed $value, [boolean $cycleCheck = false])
  • mixed $value: The value to be encoded
  • boolean $cycleCheck: Whether or not to check for possible object recursion when encoding
static encodeClass (line 379)

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

  • return: The class2 (JavaScript) encoding of the class
  • throws: Zend_Json_Exception
  • access: public
static string encodeClass ($className $className, [$package $package = ''])
  • $className $className: string The name of the class, the class must be instantiable using a null constructor
  • $package $package: string Optional package name appended to JavaScript proxy class name
static encodeClasses (line 402)

Encode several classes at once

Returns JSON encoded classes, using encodeClass().

  • access: public
static string encodeClasses ( $classNames, [string $package = ''])
  • array $classNames
  • string $package
Constructor __construct (line 58)

Constructor

  • access: protected
void __construct ([boolean $cycleCheck = false])
  • boolean $cycleCheck: Whether or not to check for recursion when encoding
_encodeArray (line 168)

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.

  • access: protected
string _encodeArray ($array &$array)
  • $array &$array: array
_encodeDatum (line 208)

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.

  • access: protected
string _encodeDatum ($value &$value)
  • $value &$value: mixed
_encodeObject (line 111)

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.

  • throws: Zend_Json_Exception If recursive checks are enabled and the object has been serialized previously
  • access: protected
string _encodeObject ($value &$value)
  • $value &$value: object
_encodeString (line 230)

JSON encode a string value by escaping characters as necessary

  • access: protected
string _encodeString ($value &$string)
  • $value &$string: string
_encodeValue (line 87)

Recursive driver which determines the type of value to be encoded

and then dispatches to the appropriate method. $values are either

  • return: Encoded value
  • access: protected
string _encodeValue ($value &$value)
  • $value &$value: mixed The value to be encoded
_wasVisited (line 145)

Determine if an object has been serialized already

  • access: protected
boolean _wasVisited ( &$value, mixed $value)
  • mixed $value
  • &$value

Documentation generated on Sun, 27 May 2007 23:22:56 -0700 by phpDocumentor 1.3.2