Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85770 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43520 invoked from network); 10 Apr 2015 16:16:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Apr 2015 16:16:59 -0000 Authentication-Results: pb1.pair.com smtp.mail=jakub.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=jakub.php@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.181 as permitted sender) X-PHP-List-Original-Sender: jakub.php@gmail.com X-Host-Fingerprint: 209.85.213.181 mail-ig0-f181.google.com Received: from [209.85.213.181] ([209.85.213.181:34962] helo=mail-ig0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D2/60-41461-977F7255 for ; Fri, 10 Apr 2015 12:16:57 -0400 Received: by iggg4 with SMTP id g4so1938230igg.0 for ; Fri, 10 Apr 2015 09:16:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=N1PLofIk3wUs+PtNN4/13yv8c2oVZqH+6MtgeUen/os=; b=01sz2xMZNcqJ3EA0Tu2sn9GYB3wBXBBFmFR87LhhvGsNZvO+SeSQDvfzY0BwWLOhHJ bE/IVtPlRaxOH44EIzzO1hdw1/vjTfiU5pLflDisD8Hp97ZSsnrzH2dPpUaaf/q/ayfC 7nHfkoDyK+E0UL/ELRzkvh1NsrzPOsp8k6PULfXI6T7JgXm7Qecw/lQuxjv1eCyiMMKp z7U5OX0WYFIcakO5Liz/AhdlYybiigDimSmGZ2DF3TKs0HYH1D/xQszB8P/4ah81BPmw aCBG6C3Z62PSEmt1OctIf6R/yrO/Gy3RwKK8UyctLR2TfOo1TWx2ocgxGOy4/HHYREwi Schg== MIME-Version: 1.0 X-Received: by 10.43.65.201 with SMTP id xn9mr4594549icb.64.1428682615113; Fri, 10 Apr 2015 09:16:55 -0700 (PDT) Sender: jakub.php@gmail.com Received: by 10.107.39.18 with HTTP; Fri, 10 Apr 2015 09:16:55 -0700 (PDT) In-Reply-To: <551C41F5.2040401@gmail.com> References: <551B9704.4030302@gmail.com> <551C41F5.2040401@gmail.com> Date: Fri, 10 Apr 2015 17:16:55 +0100 X-Google-Sender-Auth: bcOcIK8dVX8mwvI0PnrypbXkWC4 Message-ID: To: Stanislav Malyshev Cc: PHP internals list Content-Type: multipart/alternative; boundary=bcaec51f9887c54e4e051361179e Subject: Re: [PHP-DEV] JSON float number as string From: bukka@php.net (Jakub Zelenka) --bcaec51f9887c54e4e051361179e Content-Type: text/plain; charset=UTF-8 Hi, After bit of thinking I realised that it will be better to go with RFC and created an initial draft https://wiki.php.net/rfc/json_numeric_as_string . The thing that there are users asking for similar functionality for ints which is a bit controversial so it's better to have a RFC for that and also let people decide about the proposed version. Please don't comment on it till I put it under discussion (it's not completed yet). On Wed, Apr 1, 2015 at 8:07 PM, Stanislav Malyshev wrote: > Hi! > > > The encoding was just about re-using it. I wouldn't probably propose > > such constant if it was just for encoding (the main purpose is decoding > > though). I just thought that it could be a good idea to have some usage > > for encoder if it's added. It seemed to me better than just ignore it > > completely for encoder. What do you think? > > I'd have encoder to ignore it. I will add a voting options for that to the prepared RFC. > > I didn't mean it for json_encode ( apology for that as it might have > > seemed that is related just to json_encode). I meant it just as "a sort > > of" bug for json_decode as we loose information without giving user any > > way how to prevent it or at least some note in documentation about that. > > It's not actually a bug - as I said, nobody who knows anything about how > computers do numbers expects exact representation of floats. That said, > ability to *somehow* accept numbers which don't fit current precision > may be useful in some corner cases, especially when you are > interoperating with systems with different number sizes. As the old > principle goes, be liberal in what you accept and conservative in what > you produce. json_decode() option would fit this principle well. > > I still think that this is not just a useful feature. The thing is that a user has no way to get complete information from the supplied json. The json is valid for any float value (there are no limits on precision in the spec) and we don't allow to keep that information. That's a problem and it doesn't matter if we call it a bug or something else! Cheers Jakub --bcaec51f9887c54e4e051361179e--