Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85654 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55198 invoked from network); 1 Apr 2015 19:07:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Apr 2015 19:07:38 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.53 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.53 mail-pa0-f53.google.com Received: from [209.85.220.53] ([209.85.220.53:36212] helo=mail-pa0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 11/26-21906-9F14C155 for ; Wed, 01 Apr 2015 14:07:38 -0500 Received: by padcy3 with SMTP id cy3so60377647pad.3 for ; Wed, 01 Apr 2015 12:07:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=e4nAPBj2n3f3CA5STz0sDlR+Tt4jv0eUT9hk4/ztoYw=; b=hFswZPdtiCer52az5mZTo+NZAT0JwqE22Uhd9xQuXm8ca5y7wVm1pRdic4yYuJGllg +TxU0+9gqoSl/Edikw+jrPGUNU416eabNP2lgoqgi0eokvzXwRWr5Wf8tGNoIe6V4fhC auxsO97FP21nIaW10E2udalyYnCxyKt9uXl8s6a/e9EiMs04FNBaFcIr1J822QM/ZHzn aRi4Syc88ddo/Lz93zMKy8xQjEJCW+4LepvdACtqDvhiL/sxUCH4p8aywod1khXzh7wB 5ePDETT07jTPGGDbBP1khSoMHg75MsgZsjjsPZ74gVEls7b+8FxyxrhYXjrrMydslpC1 mjcQ== X-Received: by 10.70.31.66 with SMTP id y2mr81365199pdh.118.1427915255087; Wed, 01 Apr 2015 12:07:35 -0700 (PDT) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id do6sm2876572pdb.72.2015.04.01.12.07.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 12:07:34 -0700 (PDT) Message-ID: <551C41F5.2040401@gmail.com> Date: Wed, 01 Apr 2015 12:07:33 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Jakub Zelenka CC: PHP internals list References: <551B9704.4030302@gmail.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] JSON float number as string From: smalyshev@gmail.com (Stanislav Malyshev) 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 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. -- Stas Malyshev smalyshev@gmail.com