This is an old revision of the document!
PHP RFC: Replacing current json extension with jsond
- Version: 0.1
- Date: 2015-01-01
- Author: Jakub Zelenka, bukka@php.net
- Status: Under Discussion
Introduction
The current Json Parser in the json extension does not have a free license which is a problem for many Linux distros. This has been referenced at Bug #63520.
The extension code is very old and without a maintainer which makes it difficult for further improvements. There also are some implementation decisions that makes the performance worse than it should be (see benchmarks).
Proposal
The proposal is to replace the current json extension with code that is based on the PECL jsond extension (it's not exactly the same code as there are some modifications for PHP 7).
Backward Incompatible Changes
- Rejected ECMA-404 and RFC 7159 incompatible number formats in json_decode string
- top level (PHP json_decode check): 07, 0xff, .1, -.1
- all (JSON_Parser): [1.], [1.e1]
Proposed PHP Version(s)
PHP 7
RFC Impact
To SAPIs
No impact
To Existing Extensions
In addition to the backward incompatible changes for float number format the following internal changes have been done:
- removed JSON_parser.h header
- removed utf8_decode.h header
- macro JSON_PARSER_DEFAULT_DEPTH renamed to PHP_JSON_PARSER_DEFAULT_DEPTH
- error codes constants moved to php_json.h
- enum error_codes renamed to php_json_error_codes (typedef)
- ext global error_code type changed from int to php_json_error_codes
To Opcache
No impact
New Constants
None
Open Issues
None
Future Scope
- Improving performance for encoder and decoder
- Better error reporting (location of the error)
Proposed Voting Choices
50%+1 majority
Patches and Tests
The current patch for master can be seen at https://github.com/bukka/php-src/compare/jsond
The summary of the benchmarks is at https://github.com/bukka/php-jsond-bench/blob/master/reports/0001/summary.md. There also is a link for runs (measured data).
Implementation
After the project is implemented, this section will contain
- the version(s) it was merged to
- a link to the git commit(s)
References
There is an old RFC for free json parser that proposed jsonc as an replacement for json. There were some concerns about the compatibility and performance https://www.mail-archive.com/internals@lists.php.net/msg66658.html .