PHP Class Gpf_Rpc_Json

Inheritance: implements Gpf_Rpc_DataEncoder, implements Gpf_Rpc_DataDecoder
Exibir arquivo Open project: fubralimited/php-oara Class Usage Examples

Public Methods

Method Description
__construct ( integer $use ) constructs a new JSON instance
decode ( string $str ) : mixed decodes a JSON string into appropriate variable
decodeStatic ( $var )
encode ( mixed $var, $options = null ) : mixed encodes an arbitrary variable into JSON format
encodeResponse ( Gpf_Rpc_Serializable $response )
encodeStatic ( $var, $options = null )
isError ( $data, $code = null )
name_value ( string $name, mixed $value, $options = null ) : string array-walking function for use in generating JSON-formatted name-value pairs
reduce_string ( $str ) : string reduce a string by removing leading and trailing comments and whitespace
utf162utf8 ( string $utf16 ) : string convert a string from one UTF-16 char to one UTF-8 char
utf82utf16 ( string $utf8 ) : string convert a string from one UTF-8 char to one UTF-16 char

Protected Methods

Method Description
isJsonDecodeEnabled ( )
isJsonEncodeEnabled ( )

Private Methods

Method Description
getInstance ( )

Method Details

__construct() public method

constructs a new JSON instance
public __construct ( integer $use )
$use integer object behavior flags; combine with boolean-OR possible values: - SERVICES_JSON_LOOSE_TYPE: loose typing. "{...}" syntax creates associative arrays instead of objects in decode(). - SERVICES_JSON_SUPPRESS_ERRORS: error suppression. Values which can't be encoded (e.g. resources) appear as NULL instead of throwing errors. By default, a deeply-nested resource will bubble up with an error, so all return values from encode() should be checked with isError()

decode() public method

decodes a JSON string into appropriate variable
public decode ( string $str ) : mixed
$str string JSON-formatted string
return mixed number, boolean, string, array, or object corresponding to given JSON input string. See argument 1 to Services_JSON() above for object-output behavior. Note that decode() always returns strings in ASCII or UTF-8 format!

decodeStatic() public static method

public static decodeStatic ( $var )

encode() public method

encodes an arbitrary variable into JSON format
public encode ( mixed $var, $options = null ) : mixed
$var mixed any number, boolean, string, array, or object to be encoded. see argument 1 to Services_JSON() above for array-parsing behavior. if var is a strng, note that encode() always expects it to be in ASCII or UTF-8 format!
return mixed JSON string representation of input var or an error if a problem occurs

encodeResponse() public method

public encodeResponse ( Gpf_Rpc_Serializable $response )
$response Gpf_Rpc_Serializable

encodeStatic() public static method

public static encodeStatic ( $var, $options = null )

isError() public method

public isError ( $data, $code = null )

isJsonDecodeEnabled() protected method

protected isJsonDecodeEnabled ( )

isJsonEncodeEnabled() protected method

protected isJsonEncodeEnabled ( )

name_value() public method

array-walking function for use in generating JSON-formatted name-value pairs
public name_value ( string $name, mixed $value, $options = null ) : string
$name string name of key to use
$value mixed reference to an array element to be encoded
return string JSON-formatted name-value pair, like '"name":value'

reduce_string() public method

reduce a string by removing leading and trailing comments and whitespace
public reduce_string ( $str ) : string
$str string string value to strip of comments and whitespace
return string string value stripped of comments and whitespace

utf162utf8() public method

Normally should be handled by mb_convert_encoding, but provides a slower PHP-only method for installations that lack the multibye string extension.
public utf162utf8 ( string $utf16 ) : string
$utf16 string UTF-16 character
return string UTF-8 character

utf82utf16() public method

Normally should be handled by mb_convert_encoding, but provides a slower PHP-only method for installations that lack the multibye string extension.
public utf82utf16 ( string $utf8 ) : string
$utf8 string UTF-8 character
return string UTF-16 character