SunnysideUp\ShareThis\Services_JSON
Converts to and from JSON format.
Brief example of use:
<code>
// 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);
</code>
Synopsis
class Services_JSON
{
- // methods
- public void __construct()
- public string utf162utf8()
- public string utf82utf16()
- public mixed encode()
- public string name_value()
- public string reduce_string()
- public mixed decode()
- public void isError()
Tasks
Line | Task |
---|---|
767+ | Ultimately, this should just call PEAR::isError() |
Methods
public
- __construct() — constructs a new JSON instance
- decode() — decodes a JSON string into appropriate variable
- encode() — encodes an arbitrary variable into JSON format
- isError()
- name_value() — array-walking function for use in generating JSON-formatted name-value pairs
- reduce_string() — reduce a string by removing leading and trailing comments and whitespace
- utf162utf8() — convert a string from one UTF-16 char to one UTF-8 char
- utf82utf16() — convert a string from one UTF-8 char to one UTF-16 char