Class Zend_Json_Encoder

Description

Encode PHP constructs to JSON

Located in /Zend/Json/Encoder.php (line 34)


	
			
Variable Summary
 array $_visited
Method Summary
 Zend_Json_Encoder __construct ()
 string encode (mixed $value)
 string encodeClass ($className $className, [$package $package = ''])
 string encodeClasses (array $classNames, [string $package = ''])
 string _encodeArray ($array &$array)
 string _encodeConstants (ReflectionClass $cls)
 string _encodeDatum ($value &$value)
 string _encodeMethods (ReflectionClass $cls)
 string _encodeObject ($value &$value)
 string _encodeString ($value &$string)
 string _encodeValue ($value &$value)
 string _encodeVariables (ReflectionClass $cls)
 boolean _wasVisited (mixed &$value)
Variables
array $_visited = array() (line 41)

Array of visited objects; used to prevent cycling.

  • access: protected
Methods
Constructor __construct (line 46)

Constructor

  • access: protected
Zend_Json_Encoder __construct ()
encode (line 56)

Use the JSON encoding scheme for the value specified

  • return: The encoded value
  • static:
  • access: public
string encode (mixed $value)
  • mixed $value: value the object to be encoded
encodeClass (line 365)

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
  • access: public
  • static:
  • throws: Zend_Json_Exception
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
encodeClasses (line 388)

Encode several classes at once

Returns JSON encoded classes, using encodeClass().

  • access: public
  • static:
string encodeClasses (array $classNames, [string $package = ''])
  • array $classNames
  • string $package
_encodeArray (line 149)

JSON encode an array value

Recursively encodes each value of an array and returns a JSON encoded array string.

  • access: protected
string _encodeArray ($array &$array)
  • $array &$array: array
_encodeConstants (line 241)

Encode the constants associated with the ReflectionClass parameter. The encoding format is based on the class2 format

  • return: Encoded constant block in class2 format
  • access: private
  • static:
string _encodeConstants (ReflectionClass $cls)
  • $cls $cls: ReflectionClass
_encodeDatum (line 195)

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
_encodeMethods (line 267)

Encode the public methods of the ReflectionClass in the class2 format

  • return: Encoded method fragment
  • access: private
  • static:
string _encodeMethods (ReflectionClass $cls)
  • $cls $cls: ReflectionClass
_encodeObject (line 97)

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.

  • access: protected
  • throws: Zend_Json_Exception
string _encodeObject ($value &$value)
  • $value &$value: object
_encodeString (line 217)

JSON encode a string value by escaping characters as necessary

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

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
_encodeVariables (line 331)

Encode the public properties of the ReflectionClass in the class2 format.

  • return: Encode properties list
  • access: private
  • static:
string _encodeVariables (ReflectionClass $cls)
  • $cls $cls: ReflectionClass
_wasVisited (line 130)

Determine if an object has been serialized already

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

Documentation generated on Tue, 18 Apr 2006 11:54:47 -0700 by phpDocumentor 1.3.0RC3