void
&getInstance
([ $use = 0])
constructs a new JSON instance
Services_JSON
Services_JSON
([int $use = 0])
-
int
$use:
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()
decodes a JSON string into appropriate variable
mixed
decode
(string $str)
-
string
$str: JSON-formatted string
encodes an arbitrary variable into JSON format
mixed
encode
(mixed $var)
-
mixed
$var: 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!
void
isError
( $data, [ $code = null])
array-walking function for use in generating JSON-formatted name-value pairs
string
name_value
(string $name, mixed $value)
-
string
$name: name of key to use
-
mixed
$value: reference to an array element to be encoded
reduce a string by removing leading and trailing comments and whitespace
string
reduce_string
($str $str)
-
$str
$str: string string value to strip of comments and whitespace
sets use
void
setUse
(int $use)
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
utf82utf16
(string $utf8)
-
string
$utf8: UTF-8 character
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
utf162utf8
(string $utf16)
-
string
$utf16: UTF-16 character