Re: Add a new flag for json_encode

From: Date: Tue, 04 Nov 2014 18:14:13 +0000
Subject: Re: Add a new flag for json_encode
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-78658@lists.php.net to get a copy of this message
> On 4 Nov 2014, at 17:07, Jakub Zelenka <bukka@php.net> wrote: > > I would really like to see it as default in the next major as it is a > useful feature. > > However I don't like adding new flag. The reason for that is that it > becomes useless after 7 is realesed. It would be useful only for >5.6.3 and > <7.0 though. The only use case in PHP 7 would be just to disable the flag > but that won't be very nice and completely different than other json > constant usage It means doing something like $options & > ~JSON_PRESERVE_FRACTIONAL_PART ... It's a bit messy IMHO. Think that it > would be much better to wait till 7 with this feature. I really don’t like the idea of making this the default. On 32-bit systems, floats give you, effectively, extra integer range up until you hit 2^52, and indeed all JS integer values are just floats within that range. I don’t think they should be represented as floats. It’d go weirdly with 64-bit PHP, which can decode such values to integers, which would then not handle the range beyond 2^52 nicely. Also, it wouldn’t go well for cross-version compatibility with my bigint RFC here. -- Andrea Faulds http://ajf.me/

« previous php.internals (#78658) next »