PHP Класс Gpf_Rpc_Json

Наследование: implements Gpf_Rpc_DataEncoder, implements Gpf_Rpc_DataDecoder
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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

Защищенные методы

Метод Описание
isJsonDecodeEnabled ( )
isJsonEncodeEnabled ( )

Приватные методы

Метод Описание
getInstance ( )

Описание методов

__construct() публичный Метод

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() публичный Метод

decodes a JSON string into appropriate variable
public decode ( string $str ) : mixed
$str string JSON-formatted string
Результат 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 decodeStatic ( $var )

encode() публичный Метод

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!
Результат mixed JSON string representation of input var or an error if a problem occurs

encodeResponse() публичный Метод

public encodeResponse ( Gpf_Rpc_Serializable $response )
$response Gpf_Rpc_Serializable

encodeStatic() публичный статический Метод

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

isError() публичный Метод

public isError ( $data, $code = null )

isJsonDecodeEnabled() защищенный Метод

protected isJsonDecodeEnabled ( )

isJsonEncodeEnabled() защищенный Метод

protected isJsonEncodeEnabled ( )

name_value() публичный Метод

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
Результат string JSON-formatted name-value pair, like '"name":value'

reduce_string() публичный Метод

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
Результат string string value stripped of comments and whitespace

utf162utf8() публичный Метод

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
Результат string UTF-8 character

utf82utf16() публичный Метод

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
Результат string UTF-16 character