Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87330 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47662 invoked from network); 27 Jul 2015 21:54:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jul 2015 21:54:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.50 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.215.50 mail-la0-f50.google.com Received: from [209.85.215.50] ([209.85.215.50:36330] helo=mail-la0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BA/90-33169-C78A6B55 for ; Mon, 27 Jul 2015 17:54:06 -0400 Received: by lagw2 with SMTP id w2so57371281lag.3 for ; Mon, 27 Jul 2015 14:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=R2P5VQy7cn7sn8D26/zNVT2NRwMOsRxxmcbJKqtXXHg=; b=BvdZXw8+tRDF06dJ2f1mu+fWfYbklleTzEtVO3nYEtIWu2Zq4Fv6ZHnihY2yAO/zyM KfEO2mP9yEKau/b3I/rGVtajmW24gxHRdeMU/KMVBb8xrESCYN4N8EbplL3YCAyYaERy n4gWt7P0SdpvlrAt8j4887ReomHKBLX55+ghwQjzmhinotT69x8RWw4xee7aZtmTxrJS NrPZQL+hLK8gBcJSUAW8WR6qr4k4uEhONA+e4ZqCaMNbbFyryQq4en/Bsi9eFFW9QvfJ 2pde1eEsohZgE1yvnKXmcGqmCscVfStpULDryG6OZgSPgyiwqWSfEtWKvs/y7zVn8m2+ iBpA== MIME-Version: 1.0 X-Received: by 10.152.224.162 with SMTP id rd2mr29043988lac.43.1438034041139; Mon, 27 Jul 2015 14:54:01 -0700 (PDT) Received: by 10.25.90.75 with HTTP; Mon, 27 Jul 2015 14:54:01 -0700 (PDT) In-Reply-To: References: Date: Mon, 27 Jul 2015 17:54:01 -0400 Message-ID: To: Yasuo Ohgaki Cc: Jakub Zelenka , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] json_decode/encode should return full precision values by default From: ircmaxell@gmail.com (Anthony Ferrara) Yasuo, On Sun, Jul 26, 2015 at 4:20 PM, Yasuo Ohgaki wrote: > Hi Jakub, > > On Mon, Jul 27, 2015 at 3:32 AM, Jakub Zelenka wrote: > >> I don't think that this is a bug. Your example is also completely >> unrelated to json because the place when the value is rounded is var_dump >> where it's based on ini precision. You would get the same values with >> json_encode but it's only because it uses the same ini ( precision ). >> Basically it has nothing to do with json_decode. >> > > OK. Better example. > > [yohgaki@dev PHP-master]$ ./php-bin > $j = '{ "v": 0.1234567890123456789 }'; > var_dump(json_encode(json_decode($j))); > ini_set('precision', 20); > var_dump(json_encode(json_decode($j))); > ?> > > > string(22) "{"v":0.12345678901235}" > string(28) "{"v":0.12345678901234567737}" I think you missed the point. Parsing isn't dependent upon precision setting. Only dumping: http://3v4l.org/48VSt $j = '{ "v": 0.1234567890123456789 }'; $d1 = json_decode($j); ini_set('precision', 20); $d2 = json_decode($j); var_dump($d1, $d2); //object(stdClass)#1 (1) { ["v"]=> float(0.12345678901234567737) } //object(stdClass)#2 (1) { ["v"]=> float(0.12345678901234567737) } Meaning that it's parsed correctly. There is no bug here. Anthony