JSON is a lightweight data format developed by a veteran software engineer Douglas Crockford, all known as JavaScript Object Notation. The Chinese translation is a "JavaScript object representation", which can easily be converted to a JavaScript object format, used for server-side and client data transfer, to solve the problem of excessive data transfer caused by too many redundant tags in XML.
The PHP JSON class library is a PHP open source tool that automatically completes JSON encoding and decoding.
Download: Http://www.eb163.com/code/json.rar
The test_json.php contains phpunit.php, which is a unit test tool pear comes with, which can not be used in actual development.
PHP JSON class Library Sample code:
- < ?
- Create a new instance of Services_json
- Require_once (' json.php ');
- $ JSON = New Services_json ();
- Convert a complex value to JSON notation
- $ value = Array (' name ' =>' coollzh '
, ' age ' => , ' data ' =>' foo ');
- $ Output = $json- > encode ($value);
- Print ($output);
- //Send data by post: JSON =
{"Name": ' Coollzh ', "Age": 2, "Data": "foo"}
- Print ($_request[' json ');
- $ value = $json- > Decode (Str_replace
(' \ ', ' ', $_request["JSON"]));
- Var_dump ($value);
- echo " < br>". $value->data;
- ?>
I hope you can get a preliminary understanding of the specific meaning of the PHP JSON class library by using the code example above.
http://www.bkjia.com/PHPjc/446096.html www.bkjia.com true http://www.bkjia.com/PHPjc/446096.html techarticle JSON is a lightweight data format developed by a veteran software engineer Douglas Crockford, all known as JavaScript Object Notation. Chinese translation for JavaScript object representation, this lattice ...