Services_JSON Services_JSON(
[int
$use = 0]
)
|
|
constructs a new JSON instance
Parameters:
|
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()
|
mixed decode(
string
$str
)
|
|
decodes a JSON string into appropriate variable
Parameters:
|
string |
$str: |
JSON-formatted string |
API Tags:
| Return: | 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! |
| Access: | public |
mixed encode(
mixed
$var
)
|
|
encodes an arbitrary variable into JSON format
Parameters:
|
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! |
API Tags:
| Return: | JSON string representation of input var or an error if a problem occurs |
| Access: | public |
void isError(
$data, [
$code = null]
)
|
|
Parameters: