Excellent PHPJSON parser Program-PHP source code

Source: Internet
Author: User
JSOND: A Better PHPJSON parser. I'm not good at all. Let me show you a few examples. You can see if it is good. JSOND: A Better php json parser. I'm not good at all. Let me show you a few examples. You will know if it is good.

Script ec (2); script

First, let's take a look at the performance test data:

The Code is as follows:

STR: {"I": 23, "array": [1, null, false, true, ["aha", "baba", 23, {"test ": 23}]}
JSON: time for 100000 iterations: 0.238321
JSOND: time for 100000 iterations: 0.236436

STR: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
JSON: time for 100000 iterations: 0.110764
JSOND: time for 100000 iterations: 0.134212

STR: {"a": 23.2234232}
JSON: time for 100000 iterations: 0.078458
JSOND: time for 100000 iterations: 0.055479

STR: {"long-str": "At fig non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. et harum quidem rerum facilis est et expedita distinctio. nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor guest. temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. ",}
JSON: time for 100000 iterations: 0.881429
JSOND: time for 100000 iterations: 0.118529

STR:... json_encode ($ _ SERVER)
JSON: time for 100000 iterations: 4.341252
JSOND: time for 100000 iterations: 1.960814

We can see that jsond is much faster than json when there is a large amount of data.

Project address:

Github: https://github.com/bukka/php-jsond

PECL: http://pecl.php.net/package/jsond

Select the appropriate installation method based on your needs. After the installation is successful, view phpinfo:

Usage:

The Code is as follows:

Mixed jsond_decode (string $ json [, bool $ assoc = false [, int $ depth = 512 [, int $ options = 0]);
String jsond_encode (mixed $ value [, int $ options = 0 [, int $ depth = 512]);
String jsond_last_error_msg (void );
Int jsond_last_error (void );

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.