On 03/06/2021 18:03, Timon de Groot wrote:
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.
Basical
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
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.
Do you plan to add any sort of validation on negative integers?
Perhaps throw a `\ValueError` exce
On 3-6-2021 16:15, G. P. B. wrote:
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
I found that STR_OR_LONG works fine, thanks for acknowledging!
--
Kind regards,
Timon de Groot
--
PHP Inter
On Thu, 3 Jun 2021 at 11:49, Timon de Groot 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
Hello,
I have seen a similar discussion for var_export(), and the answer was
basically "use a regex". E.g.:
$json = preg_replace_callback(
'/^(?: {4})+/m',
fn ($m) => str_repeat($indent, strlen($m[0]) / 4),
json_encode($data, JSON_PRETTY_PRINT)
);
That said, I wou
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
So if you do go ahead and make an RFC for this, I think my preference
would be as a new parameter on json_encode accepting a positive integer.
Thank your for your input, I'll start working on an RFC to introduce a
new parameter for json_encode.
--
PHP Internals - PHP Runtime Development Ma
On 03/06/2021 02:45, David Gebler wrote:
I would say though (a) is true enough but doesn't necessarily cover
all use
cases, adds more magic constants and doesn't provide equivalence to the
JSON libraries of other common languages which permit for custom values,
while (b) is less of an issue with
On Wed, 2 Jun 2021, 23:03 Timon de Groot, wrote:
> It's not possible to tell json_encode what indentation level should be
> used when using
> the JSON_PRETTY_PRINT option (2, 4, 8, etc). When generating JSON files
> which can be
> used/read/edited by users, indentation starts to become a relevant
10 matches
Mail list logo