system system.base system.caching system.caching.dependencies system.collections system.console system.db system.db.ar system.db.schema system.db.schema.mssql system.db.schema.mysql system.db.schema.oci system.db.schema.pgsql system.db.schema.sqlite system.i18n system.i18n.gettext system.logging system.utils system.validators system.web system.web.actions system.web.auth system.web.filters system.web.helpers system.web.renderers system.web.services system.web.widgets system.web.widgets.captcha system.web.widgets.pagers

CJSON

system.web.helpers
继承 class CJSON
可用自 1.0
版本 $Id$
CJSON converts PHP data to and from JSON format.

公共方法

隐藏继承的方法

方法描述被定义在
decode() decodes a JSON string into appropriate variable CJSON
encode() encodes an arbitrary variable into JSON format CJSON

受保护的方法

隐藏继承的方法

方法描述被定义在
nameValue() array-walking function for use in generating JSON-formatted name-value pairs CJSON
reduceString() reduce a string by removing leading and trailing comments and whitespace CJSON
unicodeToUTF8() This function converts a Unicode array back to its UTF-8 representation CJSON
utf16beToUTF8() UTF-8 to UTF-16BE conversion. CJSON
utf8ToUTF16BE() UTF-8 to UTF-16BE conversion. CJSON
utf8ToUnicode() This function returns any UTF-8 encoded text as a list of CJSON

方法详情

decode() 方法
public static mixed decode(string $str, boolean $useArray=true)
$str string $str JSON-formatted string
$useArray boolean whether to use associative array to represent object data
{return} mixed number, boolean, string, array, or object corresponding to given JSON input string. See argument 1 to JSON() above for object-output behavior. Note that decode() always returns strings in ASCII or UTF-8 format!

decodes a JSON string into appropriate variable

encode() 方法
public static string encode(mixed $var)
$var mixed $var any number, boolean, string, array, or object to be encoded. see argument 1 to 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} string JSON string representation of input var

encodes an arbitrary variable into JSON format

nameValue() 方法
protected static string nameValue(string $name, mixed $value)
$name string $name name of key to use
$value mixed $value reference to an array element to be encoded
{return} string JSON-formatted name-value pair, like '"name":value'

array-walking function for use in generating JSON-formatted name-value pairs

reduceString() 方法
protected static string reduceString($str $str)
$str $str string string value to strip of comments and whitespace
{return} string string value stripped of comments and whitespace

reduce a string by removing leading and trailing comments and whitespace

unicodeToUTF8() 方法
protected static void unicodeToUTF8($str)
$str

This function converts a Unicode array back to its UTF-8 representation

utf16beToUTF8() 方法
protected static void utf16beToUTF8($str)
$str

UTF-8 to UTF-16BE conversion.

Maybe really UCS-2 without mb_string due to utf8ToUnicode limits

utf8ToUTF16BE() 方法
protected static void utf8ToUTF16BE($str, $bom=false)
$str
$bom

UTF-8 to UTF-16BE conversion.

Maybe really UCS-2 without mb_string due to utf8ToUnicode limits

utf8ToUnicode() 方法
protected static void utf8ToUnicode($str)
$str

This function returns any UTF-8 encoded text as a list of Unicode values: