Re: [RFC] Add json_encode indent parameter

From: Date: Tue, 05 Jul 2022 07:44:59 +0000
Subject: Re: [RFC] Add json_encode indent parameter
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-118194@lists.php.net to get a copy of this message
On 05.07.2022 09:37, Andreas Heigl wrote:
What I would have prefered is instead of a the new parameter $indent having a numerical value to have a string value. That would have allowed the following:
     json_encode($data, indent: "    ");
or
     json_encode($data, indent: "\t");
That would have made the tabs vs. spaces very easy and people can also add whatever they want to set for one indentation. Think about setting dots for making the spaces visible for some formatted output or whatever else people might think of. And setting the "indent" parameter would always implicitly set the flag "JSON_PRETTY_PRINT" (as it doesn't make sense to not have that set). The current way of just being able to set a number of spaces to indent or to use a flag for tabs is a bit fiddly at best and does make adding accessibility a second class citizen. Therefore I will vote against this current implementation.
I voted No for the same reason. -- Aleksander Machniak Kolab Groupware Developer [https://kolab.org] Roundcube Webmail Developer [https://roundcube.net] ---------------------------------------------------- PGP: 19359DC1 # Blog: https://kolabian.wordpress.com

« previous php.internals (#118194) next »