Class Zend_Json_Encoder

Description

Encode PHP constructs to JSON

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

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


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

Array of visited objects; used to prevent cycling.

  • access: protected
Methods
static method encode (line 58)

Use the JSON encoding scheme for the value specified

  • return: The encoded value
  • access: public
static string encode (mixed $value)
  • mixed $value: value the object to be encoded
static method 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
  • throws: Zend_Json_Exception
static string encodeClass (mixed $className, [mixed $package = ''])
static method 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
Constructor __construct (line 48)

Constructor

  • access: protected
Zend_Json_Encoder __construct ()
_encodeArray (line 155)

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 (mixed &$array)
_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 (mixed &$value)
_encodeObject (line 99)

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 (mixed &$value)
_encodeString (line 217)

JSON encode a string value by escaping characters as necessary

  • access: protected
string _encodeString (mixed &$string)
_encodeValue (line 75)

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 (mixed &$value)
_wasVisited (line 132)

Determine if an object has been serialized already

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

Documentation generated on Sun, 29 Oct 2006 21:27:09 -0600 by phpDocumentor 1.3.0RC6