Re: json_encode indent parameter

From: Date: Thu, 03 Jun 2021 14:15:16 +0000
Subject: Re: json_encode indent parameter
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-114711@lists.php.net to get a copy of this message
On Thu, 3 Jun 2021 at 11:49, Timon de Groot <tdegroot96@gmail.com> wrote:

> On 3-6-2021 10:00, Jordi Boggiano wrote:
> > I agree, but I'd make it accept a string|int much like JSON.stringify
> > does, because that way you let people pass in tabs too, or "🚀" if
> > that's how you want your JSON indented..
>
> I like the idea of accepting string|int.
>
> Accepting string|int means a zval needs to be used, with the possibility
> to pass any type of variable (please correct me if I'm wrong here).
> Should the function throw an error when it receives anything other than
> a string|int?
>

That's incorrect, as of PHP 8.0 Fast ZPP has a way to deal with the most
common union types, including int|string.

Best regards,

George P. Banyard


Thread (11 messages)

« previous php.internals (#114711) next »