EC-CUBE
Public メソッド
クラス Services_JSON
Services_JSONに対する継承グラフ
Inheritance graph
[凡例]

Public メソッド

 Services_JSON ($use=0)
 utf162utf8 ($utf16)
 utf82utf16 ($utf8)
 encode ($var)
 name_value ($name, $value)
 reduce_string ($str)
 decode ($str)
 isError ($data, $code=null)

説明

Converts to and from JSON format.

Brief example of use:

// create a new instance of Services_JSON $json = new Services_JSON();

// convert a complexe value to JSON notation, and send it to the browser $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4))); $output = $json->encode($value);

print($output); // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]

// accept incoming POST data, assumed to be in JSON notation $input = file_get_contents('php://input', 1000000); $value = $json->decode($input);


関数

decode ( str)

decodes a JSON string into appropriate variable

引数:
string$strJSON-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! public

LC_Upgrade_Helper_Jsonで再定義されています。

encode ( var)

encodes an arbitrary variable into JSON format

引数:
mixed$varany 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 public
isError ( data,
code = null 
)
TODO:
Ultimately, this should just call PEAR::isError()
name_value ( name,
value 
)

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

引数:
string$namename of key to use
mixed$valuereference to an array element to be encoded
戻り値:
string JSON-formatted name-value pair, like '"name":value' private
reduce_string ( str)

reduce a string by removing leading and trailing comments and whitespace

引数:
$strstring string value to strip of comments and whitespace
戻り値:
string string value stripped of comments and whitespace private
Services_JSON ( use = 0)

constructs a new JSON instance

引数:
int$useobject 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()
utf162utf8 ( utf16)

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.

引数:
string$utf16UTF-16 character
戻り値:
string UTF-8 character private
utf82utf16 ( utf8)

convert a string from one UTF-8 char to one UTF-16 char

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

引数:
string$utf8UTF-8 character
戻り値:
string UTF-16 character private

このクラスの説明は次のファイルから生成されました:
 全て データ構造 ネームスペース 関数 変数