PHPJSON class library example _ PHP Tutorial

Source: Internet
Author: User
Tags php json
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:

 
 
  1. <?
  2. // Create a new instance of Services_JSON
  3. Require_once ('json. php ');
  4. $ Json = new Services_JSON ();
  5. // Convert a complex value to JSON notation
  6. $ Value = array ('name' => 'coollzh'
    , 'Age' => 22, 'data' => 'Foo ');
  7. $ Output = $ json-> encode ($ value );
  8. Print ($ output );
  9. // Use the post method to send data: json =
    {"Name": 'coollzh ', "age": 2, "data": "foo "}
  10. Print ($ _ REQUEST ['json']);
  11. $ Value = $ json-> decode (str_replace
    ('\', '', $ _ REQUEST [" json "]);
  12. Var_dump ($ value );
  13. Echo "<br>". $ value-> data;
  14. ?>

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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.