On Thu, Jun 3, 2021 at 6:11 PM Timon de Groot <tdegroo...@gmail.com> wrote:

> Hi internals,
>
> I'd like to present my RFC for adding the indent parameter to the
> json_encode function:
>    https://wiki.php.net/rfc/json_encode_indentation
>
> The `string|int $indent = 4` parameter adds the ability to specify the
> indentation for
> the JSON encoder. Amount of spaces can be specified by a number and a
> string can be
> specified to set a custom indentation like `\t` or whatever.
>
> As this is my first RFC (and contribution) for PHP, I'm all kind of new
> to the process, standards, etc.
> Please let me know if I could do something better.
>
> Looking forward to feedback/input on the RFC.
>

As has been brought up in
https://github.com/php/php-src/pull/7093#issuecomment-855170601, the string
version of the $indent parameter allows you to create invalid JSON,
something that json_encode() does not currently allow. I tend to agree that
it would make sense to validate that the indent only contains whitespace
characters, and not 🚀.

Regards,
Nikita

Reply via email to