Re: [PHP-DEV] [Pre-RFC] Opt-in JSON comments and trailing commas

"Larry Garfield" <[email protected]>
Newsgroups gmane.comp.php.devel
Message-ID <[email protected]>
On Mon, Aug 17, 2026, at 1:18 PM, Otar Chekurishvili wrote:
> Hello!
>
> I would like to discuss a draft RFC that adds two independent and 
> opt-in flags to ext/json for PHP 8.7:
>
> - JSON_ALLOW_COMMENTS
> - JSON_ALLOW_TRAILING_COMMAS
>
> Both flags would be accepted by json_decode() and json_validate(). 
> Strict JSON would remain the default. Comments are limited to // and 
> non-nesting /* ... */ at JSON whitespace boundaries. Trailing commas 
> permit one comma after the last element or member of a nonempty array 
> or object.
>
> The implementation processes comments in the existing re2c scanner. It 
> handles trailing commas in the existing Bison grammar. It does not 
> preprocess or copy the input, so it preserves strings and original 
> source locations. The RFC uses two primary votes so that either 
> extension can be accepted independently.
>
> Draft implementation is located here: https://github.com/php/php-src/pull/23336
>
> Recently I also published a similar PHP library: https://github.com/otar/jsonc
>
> I would particularly appreciate feedback on the API names and the 
> inclusion of json_validate(). Feedback on the specified UTF-8, 
> control-character, and error-location behavior would also be useful.
>
>
> Otar

Does this essentially mean JSON5 support?  If so, just call it that.  (I am undecided on the best way to support that.)

--Larry Garfield
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.