fJSONstatic classv1.0.0b4
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.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 |
Constants
::J_ARRAY_CLOSEinternal
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 ]
::J_ARRAY_COMMAinternal
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
::J_ARRAY_OPENinternal
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 [
::J_COLONinternal
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 :
::J_FALSEinternal
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
::J_FLOATinternal
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
::J_INTEGERinternal
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
::J_KEYinternal
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
::J_NULLinternal
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
::J_OBJ_CLOSEinternal
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 }
::J_OBJ_COMMAinternal
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
::J_OBJ_OPENinternal
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 {
::J_STRINGinternal
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
::J_TRUEinternal
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
Static Methods
::decode() public
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.
Signature
array|stdClass decode( string $json, boolean $assoc=FALSE )
Parameters
| 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 |
Returns
A PHP equivalent of the JSON string
::encode() public
Encodes a PHP value into a JSON string
Signature
string encode( mixed $value )
Parameters
| mixed | $value | The PHP value to encode |
Returns
The JSON string that is equivalent to the PHP value
::sendHeader() public
Sets the proper Content-Type header for UTF-8 encoded JSON
Signature
void sendHeader( )
