Detailed introduction PHP JSON class Library application Example _php tutorial

Source: Internet
Author: User
Tags php json

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:

 
 
  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 ' => , ' data ' =>' foo ');
  7. $ Output = $json- > encode ($value);
  8. Print ($output);
  9. //Send data by post: 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. ?>

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

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