This is a good news. PHP 5.2 support json. It's very easy to use. I like it, because I can transfer data between javascript and php freely accroading to this functions.
json_encode
(PHP 5 >= 5.2.0, PECL json:1.2.0-1.2.1)
json_encode — Returns the JSON representation of a value
Description
string json_encode ( mixed $value )
Returns a string containing the JSON representation of value.
Parameters
value
The value being encoded. Can be any type except a resource.
This function only works with UTF-8 encoded data.
Return Values
Returns a JSON encoded string on success.
json_decode
(PHP 5 >= 5.2.0, PECL json:1.2.0-1.2.1)
json_decode — Decodes a JSON string
Description
mixed json_decode ( string $json [, bool $assoc] )
Takes a JSON encoded string and converts it into a PHP variable.
Parameters
json
The json string being decoded.
assoc
When TRUE, returned objects will be converted into associative arrays.
Return Values
Returns an object or if the optional assoc parameter is TRUE, an associative array is instead returned.
please link to www.php.net for more information.
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/binghuiliang/archive/2007/09/03/1770047.aspx