rfc:free-json-parser
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:free-json-parser [2013/08/25 16:49] – [New Constants] remi | rfc:free-json-parser [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Switch from json extension to jsonc ====== | ====== PHP RFC: Switch from json extension to jsonc ====== | ||
- | * Version: | + | * Version: 1.0 |
* Date: 2013-08-25 | * Date: 2013-08-25 | ||
* Author: Remi Collet < | * Author: Remi Collet < | ||
- | * Status: | + | * Status: Under Discussion |
* First Published at: https:// | * First Published at: https:// | ||
Line 15: | Line 15: | ||
Effectively, | Effectively, | ||
- | The encoder code is free since PHP 5.4.10 ([[https:// | + | The encoder code is free since PHP 5.4.10 ([[https:// |
===== Proposal ===== | ===== Proposal ===== | ||
- | The extension | + | The **jsonc** extension, currently available from PECL site is designed to be a dropin alternative |
- | * Same encoder | + | * Same **encoder** as in PHP 5.5 |
- | * Parser provided by the [[https:// | + | |
- | As the new parser | + | While the main purpose of this RFC is to fix the Licensing issue, it also introduce some new features. |
+ | As the new parser is an incremental one, the new **JsonIncrementalParser** class expose this feature | ||
< | < | ||
Line 34: | Line 35: | ||
} while ($buf && ($ret==JsonIncrementalParser:: | } while ($buf && ($ret==JsonIncrementalParser:: | ||
$result = $parser-> | $result = $parser-> | ||
+ | </ | ||
+ | |||
+ | Or, allow to parse a file without having to load it into memory: | ||
+ | < | ||
+ | $parser = new JsonIncrementalParser(); | ||
+ | $ret = $parser-> | ||
+ | $result = $parser-> | ||
+ | </ | ||
+ | |||
+ | The json-c parser provides 2 strictness mode: | ||
+ | * strict mode, used by default (for compatibility with previous implementation) | ||
+ | * standard mode, available using the JSON_PARSER_NOTSTRICT option | ||
+ | |||
+ | Having a **not-strict parser** could be usefull for reading configuration from manually edited file, such as: | ||
+ | < | ||
+ | /* | ||
+ | Foo configuration file | ||
+ | */ | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
</ | </ | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | Partial implementation of big integers parsing (and of JSON_BIGINT_AS_STRING option). This will only work in a 32bits | + | Partial implementation of big integers parsing (and of JSON_BIGINT_AS_STRING option). This will only work in a 32bits |
+ | |||
+ | As the new parser implement different error codes, parser error is always returned by **json_last_error()** as JSON_ERROR_SYNTAX (JSON_ERROR_STATE_MISMATCH and JSON_ERROR_CTRL_CHAR are kept for compatibility but never used). | ||
+ | |||
+ | **json_last_error_msg()** returns error string from the json-c library. | ||
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
Line 48: | Line 76: | ||
* **Debian** since PHP 5.5 / Jessie | * **Debian** since PHP 5.5 / Jessie | ||
* **Fedora** since PHP 5.5 / Fedora 19 | * **Fedora** since PHP 5.5 / Fedora 19 | ||
- | * **Mageia** | + | * **Mageia** |
* **Ubuntu** since PHP 5.5 / Saucy | * **Ubuntu** since PHP 5.5 / Saucy | ||
Line 57: | Line 85: | ||
===== Impact to Existing Extensions ===== | ===== Impact to Existing Extensions ===== | ||
- | * replace json extension by jsonc | + | * replace json extension by jsonc (of course, renamed to json) |
===== New Constants ===== | ===== New Constants ===== | ||
Line 77: | Line 105: | ||
===== Unaffected PHP Functionality ===== | ===== Unaffected PHP Functionality ===== | ||
- | List existing areas/ | + | No change in PHP engine. |
- | + | No change for other extension. | |
- | This helps avoid any ambiguity, shows that you have thought deeply about the RFC's impact, and helps reduces mail list noise. | + | |
===== Future Scope ===== | ===== Future Scope ===== | ||
- | This sections details areas where the feature might be improved in future, but that are not currently proposed in this RFC. | + | Speed improvment. |
+ | |||
+ | As the original author (omar) seems no more involed, I could maintain | ||
+ | Implement some RFE such as [[https:// | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
- | Include these so readers know where you are heading and can discuss the proposed voting options. | + | * Yes (switch from json to jsonc in php 5.6) |
+ | * No (keep using non-free stuff in php) | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== |
rfc/free-json-parser.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1