Docs For Class Zend_Json_Decoder

## Class Zend_Json_Decoder

Description

Decode JSON encoded string to PHP variable constructs

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

Located in /Zend/Json/Decoder.php (line 46)

Class Constant Summary
COLON = 7
COMMA = 6
DATUM = 1
EOF = 0
LBRACE = 2
LBRACKET = 3
RBRACE = 4
RBRACKET = 5
Variable Summary
int $_decodeType
int $_offset
string $_source
int $_sourceLength
int $_token
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 97)

Flag indicating how objects should be decoded

- access: protected

int $_offset (line 82)

The offset within the souce being decoded

- access: protected

string $_source (line 67)

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

- access: protected

int $_sourceLength (line 74)

Caches the source length

- access: protected

int $_token (line 89)

The current token being considered in the parser cycle

- access: protected

Methods
static method decode (line 155)

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.

- access: public
- throws: Zend_Json_Exception

static mixed decode ([string $source = null], [int $objectDecodeType = Zend_Json::TYPE_ARRAY])

- string $source: String to be decoded
- int $objectDecodeType: How objects should be decoded; should be either or Zend_Json::TYPE_ARRAY or Zend_Json::TYPE_OBJECT; defaults to TYPE_ARRAY

Constructor __construct (line 108)

Constructor

- access: protected

void __construct (string $source, int $decodeType)

- string $source: String source to decode
- int $decodeType: How objects should be decoded -- see Zend_Json::TYPE_ARRAY and Zend_Json::TYPE_OBJECT for valid values

_decodeArray (line 264)

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

- access: protected

array _decodeArray ()
_decodeObject (line 208)

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 174)

Recursive driving rountine for supported toplevel tops

- access: protected

mixed _decodeValue ()
_eatWhitespace (line 294)

Removes whitepsace characters from the source input

- access: protected

void _eatWhitespace ()
_getNextToken (line 314)

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 60)
COMMA = 6 (line 59)
DATUM = 1 (line 54)
EOF = 0 (line 53)

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 55)
LBRACKET = 3 (line 56)
RBRACE = 4 (line 57)
RBRACKET = 5 (line 58)

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