Class Zend_Json_Decoder

Description

Decode JSON encoded string to PHP variable constructs

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

Located in /Json/Decoder.php (line 40)


	
			
Class Constant Summary
 COLON = 7
 COMMA = 6
 DATUM = 1
 EOF = 0
 LBRACE = 2
 LBRACKET = 3
 RBRACE = 4
 RBRACKET = 5
Variable Summary
Method Summary
 static mixed decode ([string $source = null], [int $objectDecodeType = Zend_Json::TYPE_ARRAY])
 void __construct (string $source, int $decodeType)
 array _decodeArray ()
 array|StdClass _decodeObject ()
 mixed _decodeValue ()
 void _eatWhitespace ()
 int _getNextToken ()
Variables
int $_decodeType (line 91)

Flag indicating how objects should be decoded

  • access: protected
int $_offset (line 76)

The offset within the souce being decoded

  • access: protected
string $_source (line 61)

Use to maintain a "pointer" to the source being decoded

  • access: protected
int $_sourceLength (line 68)

Caches the source length

  • access: protected
int $_token (line 83)

The current token being considered in the parser cycle

  • access: protected
Methods
static decode (line 149)

Decode a JSON source string

Decodes a JSON encoded string. The value returned will be one of the following:

  • integer
  • float
  • boolean
  • StdClass
  • array of one or more of the above types
By default, decoded objects will be returned as associative arrays; to return a StdClass object instead, pass Zend_Json::TYPE_OBJECT to the $objectDecodeType parameter.

Throws a Zend_Json_Exception if the source string is null.

  • throws: Zend_Json_Exception
  • access: public
static mixed decode ([string $source = null], [int $objectDecodeType = Zend_Json::TYPE_ARRAY])
Constructor __construct (line 102)

Constructor

  • access: protected
void __construct (string $source, int $decodeType)
_decodeArray (line 258)

Decodes a JSON array format: [element, element2,...,elementN]

  • access: protected
array _decodeArray ()
_decodeObject (line 202)

Decodes an object of the form: { "attribute: value, "attribute2" : value,...}

If ZJsonEnoder or ZJAjax was used to encode the original object then a special attribute called __className which specifies a class name that should wrap the data contained within the encoded source.

Decodes to either an array or StdClass object, based on the value of $_decodeType. If invalid $_decodeType present, returns as an array.

  • access: protected
array|StdClass _decodeObject ()
_decodeValue (line 168)

Recursive driving rountine for supported toplevel tops

  • access: protected
mixed _decodeValue ()
_eatWhitespace (line 288)

Removes whitepsace characters from the source input

  • access: protected
void _eatWhitespace ()
_getNextToken (line 308)

Retrieves the next token from the source stream

  • return: Token constant value specified in class definition
  • access: protected
int _getNextToken ()
Class Constants
COLON = 7 (line 54)
COMMA = 6 (line 53)
DATUM = 1 (line 48)
EOF = 0 (line 47)

Parse tokens used to decode the JSON object. These are not for public consumption, they are just used internally to the class.

LBRACE = 2 (line 49)
LBRACKET = 3 (line 50)
RBRACE = 4 (line 51)
RBRACKET = 5 (line 52)

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