# [RFC] Opt-in JSON Comments and Trailing Commas

- Thread: https://externals.io/message/132868
- Original archive: https://news-web.php.net/php.internals/132868
- Started by Otar Chekurishvili on 2026-10-13T18:36:13+00:00
- Messages: 3
- RFC: Opt-in JSON Comments and Trailing Commas (Under discussion) — https://externals.io/rfc/json_comments_trailing_commas.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #132868 — Otar Chekurishvili — 2026-10-13T18:36:13+00:00

URL: https://externals.io/message/132868#132868

Hello internals,

I want to start the discussion of the RFC "Opt-in JSON Comments and
Trailing Commas":
<https://wiki.php.net/rfc/json_comments_trailing_commas>

The RFC adds two independent opt-in flags for `json_decode()` and
 `json_validate()`:

- JSON_ALLOW_COMMENTS accepts // line comments and /* block comments */.
- JSON_ALLOW_TRAILING_COMMAS accepts one comma after the last item of a
non-empty array or object.

Strict JSON stays the default. `json_encode()` does not change.

This RFC follows the pre-RFC thread:
<https://news-web.php.net/php.internals/132236>

Thank you for the feedback in that thread. The RFC now answers it:

- The RFC does not add JSON5. It compares the two flags with JSON5,
JSONC and JWCC (Larry, Anton).
- The RFC keeps two flags, not one JSON_ALLOW_JSONC flag. The JSONC
specification is a draft, and it makes trailing commas optional. The
section "Rejected Features" gives all reasons (Tim).
- The RFC includes test results and performance measurements.

The implementation is here:
<https://github.com/php/php-src/pull/23336>

The RFC has two primary votes, one for each flag. Each vote needs a 2/3
majority.

All feedback is welcome.

Otar

---

## #132869 — tim@bastelstu.be — 2026-10-13T18:49:46+00:00

URL: https://externals.io/message/132868#132869 · In reply to: #132868

Hi


> - The RFC keeps two flags, not one JSON_ALLOW_JSONC flag. The JSONC
> specification is a draft, and it makes trailing commas optional. The
> section "Rejected Features" gives all reasons (Tim).

I'm not happy, but the rejected is well-argued :-)

-----

I've given the RFC a full read and don't have any (other) comments. The 
RFC is incredibly well-written, thank you!

Just don't forget to add the link to the discussion thread at the header 
section: https://news-web.php.net/php.internals/132868

Best regards
Tim Düsterhus

---

## #132870 — Larry Garfield — 2026-10-13T21:08:29+00:00

URL: https://externals.io/message/132868#132870 · In reply to: #132868

> Hello internals,
>
> I want to start the discussion of the RFC "Opt-in JSON Comments and 
> Trailing Commas":
> https://wiki.php.net/rfc/json_comments_trailing_commas
>
> The RFC adds two independent opt-in flags for `json_decode()` and `json_validate()`:
>
> - JSON_ALLOW_COMMENTS accepts // line comments and /* block comments */.
> - JSON_ALLOW_TRAILING_COMMAS accepts one comma after the last item of a 
> non-empty array or object.
>
> Strict JSON stays the default. `json_encode()` does not change.
>
> This RFC follows the pre-RFC thread:
> https://news-web.php.net/php.internals/132236
>
> Thank you for the feedback in that thread. The RFC now answers it:
>
> - The RFC does not add JSON5. It compares the two flags with JSON5, 
> JSONC and JWCC (Larry, Anton).
> - The RFC keeps two flags, not one JSON_ALLOW_JSONC flag. The JSONC 
> specification is a draft, and it makes trailing commas optional. The 
> section "Rejected Features" gives all reasons (Tim).
> - The RFC includes test results and performance measurements.
>
> The implementation is here:
> https://github.com/php/php-src/pull/23336
>
> The RFC has two primary votes, one for each flag. Each vote needs a 2/3 
> majority.
>
> All feedback is welcome.
>
> Otar

I am forced to agree with Tim.  This is a very tight RFC, and I have no remaining objections to it.  Nicely done!

--Larry Garfield
