PHPDoctor


NoPackageTagFound\Services_JSON
facebook_client/jsonwrapper/JSON/JSON.php at line 115

Class Services_JSON

Services_JSON

public class Services_JSON

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);


Method Summary
void

__construct(int use)

constructs a new JSON instance

mixed

decode(string str)

decodes a JSON string into appropriate variable

mixed

encode(mixed var)

encodes an arbitrary variable into JSON format

void

isError(mixed data, mixed code)

Method Detail

facebook_client/jsonwrapper/JSON/JSON.php at line 133

__construct

public void __construct(int use)

constructs a new JSON instance

Parameters:
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()

facebook_client/jsonwrapper/JSON/JSON.php at line 484

decode

public mixed decode(string str)

decodes a JSON string into appropriate variable

Parameters:
str - JSON-formatted string
Returns:
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!

facebook_client/jsonwrapper/JSON/JSON.php at line 237

encode

public mixed encode(mixed var)

encodes an arbitrary variable into JSON format

Parameters:
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!
Returns:
JSON string representation of input var or an error if a problem occurs

facebook_client/jsonwrapper/JSON/JSON.php at line 766

isError

public void isError(mixed data, mixed code)

Todo:
Ultimately, this should just call PEAR::isError()

PHPDoctor