
Provides encoding and decoding for JSON
This class is a compatibility class for the json extension on servers with PHP 5.0 or 5.1, or servers with the json extension compiled out.
This class will handle JSON values that are not contained in an array or object - such values are not valid according to the JSON spec, but the functionality is included for compatiblity with the json extension.
1.0.0b6 | Removed e flag from preg_replace() calls 6/8/10 |
---|---|
1.0.0b5 | Added the output() method 3/15/10 |
1.0.0b4 | Fixed a bug with decode() where JSON objects could lose all but the first key: value pair 5/6/09 |
1.0.0b3 | Updated the class to be consistent with PHP 5.2.9+ for encoding and decoding invalid data 5/4/09 |
1.0.0b2 | Changed @ error suppression operator to error_reporting() calls 1/26/09 |
1.0.0b | The initial implementation 7/12/08 |
Please note: this constant is primarily intended for internal use by Flourish and will normally not be useful in site/application code
An abstract representation of ]
Please note: this constant is primarily intended for internal use by Flourish and will normally not be useful in site/application code
An abstract representation of , in a JSON array
Please note: this constant is primarily intended for internal use by Flourish and will normally not be useful in site/application code
An abstract representation of [
Please note: this constant is primarily intended for internal use by Flourish and will normally not be useful in site/application code
An abstract representation of :
Please note: this constant is primarily intended for internal use by Flourish and will normally not be useful in site/application code
An abstract representation of a boolean false
Please note: this constant is primarily intended for internal use by Flourish and will normally not be useful in site/application code
An abstract representation of a floating value
Please note: this constant is primarily intended for internal use by Flourish and will normally not be useful in site/application code
An abstract representation of an integer
Please note: this constant is primarily intended for internal use by Flourish and will normally not be useful in site/application code
An abstract representation of a JSON object key
Please note: this constant is primarily intended for internal use by Flourish and will normally not be useful in site/application code
An abstract representation of null
Please note: this constant is primarily intended for internal use by Flourish and will normally not be useful in site/application code
An abstract representation of }
Please note: this constant is primarily intended for internal use by Flourish and will normally not be useful in site/application code
An abstract representation of , in a JSON object
Please note: this constant is primarily intended for internal use by Flourish and will normally not be useful in site/application code
An abstract representation of {
Please note: this constant is primarily intended for internal use by Flourish and will normally not be useful in site/application code
An abstract representation of a string
Please note: this constant is primarily intended for internal use by Flourish and will normally not be useful in site/application code
An abstract representation of a boolean true
Decodes a JSON string into native PHP data types
This function is very strict about the format of JSON. If the string is not a valid JSON string, NULL will be returned.
array|stdClass decode( string $json, boolean $assoc=FALSE )
string | $json | This should be the name of a related class |
boolean | $assoc | If this is TRUE, JSON objects will be represented as an assocative array instead of a stdClass object |
A PHP equivalent of the JSON string
Encodes a PHP value into a JSON string
string encode( mixed $value )
mixed | $value | The PHP value to encode |
The JSON string that is equivalent to the PHP value
Sets the proper Content-Type header and outputs the value, encoded as JSON
void output( mixed $value )
mixed | $value | The PHP value to output as JSON |
Sets the proper Content-Type header for UTF-8 encoded JSON
void sendHeader( )