This section describes the PHPJSON class library application examples in detail. JSON is a lightweight data format developed by DouglasCrockford, a senior software engineer. it is called JavascriptObjectNotation. The Chinese translation is represented by a JavaScript object.
JSON is a lightweight data format developed by Douglas Crockford, a senior software engineer. it is called Javascript Object Notation. The Chinese translation is "JavaScript Object Representation". The data in this format can be easily converted to the javascript Object format for data transmission on the server side and the client side, it is used to solve the problem of excessive data transmission caused by excessive redundant labels in xml.
The php json class library is an open-source php tool that automatically completes JSON encoding and decoding.
Download: http://www.eb163.com/code/json.rar
TEST_JSON.php contains PHPUnit. php, which is a unit test tool provided by PEAR. it is not 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' => 22, 'data' => 'Foo ');
- $ Output = $ json-> encode ($ value );
- Print ($ output );
- // Use the post method to send data: json =
{"Name": 'coollzh ', "age": 2, "data": "foo "}
- Print ($ _ REQUEST ['json']);
- $ Value = $ json-> decode (str_replace
('\', '', $ _ REQUEST [" json "]);
- Var_dump ($ value );
- Echo "<br>". $ value-> data;
- ?>
We hope that you can get a preliminary understanding of the specific meaning of the above php json class library code example.
Developed by Crockford, it is called Javascript Object Notation. The Chinese translation is represented by a JavaScript object...