API Documentation

Json/Decoder.php

Includes Classes 
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Json
version
$Id: Decoder.php 22655 2010-07-22 18:47:20Z mabe $
Classes
Zend_Json_Decoder

Description

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Zend_Json_Decoder

category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Json
Constants
EOF
DATUM
LBRACE
LBRACKET
RBRACE
RBRACKET
COMMA
COLON
Properties
$_source
$_sourceLength
$_offset
$_token
$_decodeType
Methods
__construct
decode
_decodeValue
_decodeObject
_decodeArray
_eatWhitespace
_getNextToken
decodeUnicodeString
_utf162utf8

Description

Decode JSON encoded string to PHP variable constructs

Constants

EOF

 EOF = '0'

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

Details

value
0

DATUM

 DATUM = '1'

Details

value
1

LBRACE

 LBRACE = '2'

Details

value
2

LBRACKET

 LBRACKET = '3'

Details

value
3

RBRACE

 RBRACE = '4'

Details

value
4

RBRACKET

 RBRACKET = '5'

Details

value
5

COMMA

 COMMA = '6'

Details

value
6

COLON

 COLON = '7'

Details

value
7

Properties

$_decodeType

int $_decodeType = ''

Flag indicating how objects should be decoded

Details

$_decodeType
int
visibility
protected
default
final
false
static
false
access
protected

$_offset

int $_offset = ''

The offset within the souce being decoded

Details

$_offset
int
visibility
protected
default
final
false
static
false

$_source

string $_source = ''

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

Details

$_source
string
visibility
protected
default
final
false
static
false

$_sourceLength

int $_sourceLength = ''

Caches the source length

Details

$_sourceLength
int
visibility
protected
default
final
false
static
false

$_token

int $_token = ''

The current token being considered in the parser cycle

Details

$_token
int
visibility
protected
default
final
false
static
false

Methods

__construct

__construct( string $source, int $decodeType ) : void

Constructor

Arguments
$source
string
String source to decode
$decodeType
int
How objects should be decoded -- see {@link Zend_Json::TYPE_ARRAY} and {@link Zend_Json::TYPE_OBJECT} for valid values
Details
visibility
protected
final
false
static
false

_decodeArray

_decodeArray( ) : array

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

Output
array
Details
visibility
protected
final
false
static
false

_decodeObject

_decodeObject( ) : array|StdClass

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

If Zend_Json_Encoder 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 {@link $_decodeType}. If invalid $_decodeType present, returns as an array.

Output
array|StdClass
Details
visibility
protected
final
false
static
false

_decodeValue

_decodeValue( ) : mixed

Recursive driving rountine for supported toplevel tops

Output
mixed
Details
visibility
protected
final
false
static
false

_eatWhitespace

_eatWhitespace( ) :

Removes whitepsace characters from the source input

Details
visibility
protected
final
false
static
false

_getNextToken

_getNextToken( ) : int

Retrieves the next token from the source stream

Output
int
Token constant value specified in class definition
Details
visibility
protected
final
false
static
false

_utf162utf8

_utf162utf8( string $utf16 ) : string

Convert a string from one UTF-16 char to one UTF-8 char.

Normally should be handled by mb_convert_encoding, but provides a slower PHP-only method for installations that lack the multibye string extension.

This method is from the Solar Framework by Paul M. Jones

Arguments
$utf16
string
UTF-16 character
Output
string
UTF-8 character
Details
visibility
protected
final
false
static
true
link
http://solarphp.com

decode

decode( string $source = null, int $objectDecodeType = Zend_Json ) : mixed

Decode a JSON source string

Decodes a JSON encoded string. The value returned will be one of the following: - integer - float - boolean - null - StdClass - array - 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 {@link Zend_Json::TYPE_OBJECT} to the $objectDecodeType parameter.

Throws a Zend_Json_Exception if the source string is null.

Arguments
$source
string
String to be decoded
$objectDecodeType
int
How objects should be decoded; should be either or {@link Zend_Json::TYPE_ARRAY} or {@link Zend_Json::TYPE_OBJECT}; defaults to TYPE_ARRAY
Output
mixed
Details
visibility
public
final
false
static
true
access
public
static
throws

decodeUnicodeString

decodeUnicodeString(  $chrs ) : string

Decode Unicode Characters from \u0000 ASCII syntax.

This algorithm was originally developed for the Solar Framework by Paul M. Jones

Arguments
$chrs
Output
string
Details
visibility
public
final
false
static
true
link
http://solarphp.com/
link
http://svn.solarphp.com/core/trunk/Solar/Json.php
Documentation was generated by DocBlox.