Re: json_encode indent parameter

From: Date: Thu, 03 Jun 2021 16:03:42 +0000
Subject: Re: json_encode indent parameter
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-114716@lists.php.net to get a copy of this message
On 3-6-2021 17:53, Ayesh Karunaratne wrote:
Hi Timon, Thank you for this RFC. I think the string|int $indent approach is great 🚀! Reading the PR, it looks like $indent=0 is essentially turning off pretty-print, which I think is intuitive. Basically, yes. With $indent=0, no indentation will take place but new lines will still be added.
Do you plan to add any sort of validation on negative integers? Perhaps throw a \ValueError exception on $indent < 0?
Good question. Personally I'd prefer clamping $indent to 0 when it reaches below 0. But I'd like to hear about what other particpants think about such behavior. Thank you for your feedback :). -- Kind regards, Timon de Groot

« previous php.internals (#114716) next »