Re: Add a new flag for json_encode
| From: | Andrea Faulds | Date: | Tue, 04 Nov 2014 20:51:08 +0000 |
| Subject: | Re: Add a new flag for json_encode | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-78681@lists.php.net to get a copy of this message | ||
> On 4 Nov 2014, at 20:06, Jakub Zelenka <bukka@php.net> wrote:
>
> That's a good point. However I still think that there are more advantages for making this
> the default. I like mainly the idea that json_decode(json_encode($a)) = $a for all floats which is
> not the case at the moment. Also it allow some other things that were mentioned before.
It won’t be with or without your changes, as JSON can’t encode Infinity or NaN.
Also, I don’t think it matters. PHP isn’t a strictly-typed language where there’s an important
difference between float(7000) and int(7000). They act exactly the same in all contexts.
There’s no benefit to this change that I can see within PHP (perhaps with other languages that
have weird JSON parsers), and it causes problems as I’ve said above. Thus, I can’t support it
being a default.
--
Andrea Faulds
http://ajf.me/