Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87295 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47441 invoked from network); 25 Jul 2015 22:17:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jul 2015 22:17:40 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.171 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.160.171 mail-yk0-f171.google.com Received: from [209.85.160.171] ([209.85.160.171:36107] helo=mail-yk0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AF/91-28932-30B04B55 for ; Sat, 25 Jul 2015 18:17:39 -0400 Received: by ykay190 with SMTP id y190so44102373yka.3 for ; Sat, 25 Jul 2015 15:17:36 -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:from:date:message-id :subject:to:content-type; bh=VTXRlzMXBGRUosW9LszpFbtD+57q1hnf8ssqjdQo9Oo=; b=rUCm6EPXVk6Q9TGELYQdtWMknl1KN0RXOjCUG8uU4Pf5y/TFySblp9Pwh8SLek/AvF 7VNjRPruDQxdiMkxGh+3Gu7w7ewIITUi3pTCyBo4l7TtHPiE35TXIDshHYBsBuV6tNtZ gwj/whLuCiNWjIf7CMUOTrpmO7QZqG672WQTEFPD4KYGOkPGCukAw/eSNj2Zp0M6MVrN wXG9xdQUXvUipNTMZ5m3QtotIOq1WAmcVO0UHp40K7dyypUn6HMLIyPq6W1t+IHn0LxS ujpbt/bl5w1B5zwCI1eLIRRgVp+ehq9w0qZ7weWH59vzJ8Ta9Tg/VVUDSbFKcJAZ3jmV A6mA== X-Received: by 10.170.215.69 with SMTP id h66mr21892976ykf.74.1437862656199; Sat, 25 Jul 2015 15:17:36 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.129.40.77 with HTTP; Sat, 25 Jul 2015 15:16:56 -0700 (PDT) In-Reply-To: References: Date: Sun, 26 Jul 2015 07:16:56 +0900 X-Google-Sender-Auth: vogWAcuDSAJedSER6gLCQ5LC1lY Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a113bcfa0dbd66a051bba7cd9 Subject: Re: json_decode/encode should return full precision values by default From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a113bcfa0dbd66a051bba7cd9 Content-Type: text/plain; charset=UTF-8 Hi all, Created bug report for this issue. https://bugs.php.net/bug.php?id=70137 -- Yasuo Ohgaki yohgaki@ohgaki.net On Sun, Jul 26, 2015 at 7:01 AM, Yasuo Ohgaki wrote: > Hi all, > > I had to work with Google Map API and need to handle values precisely. > Fortunately, it seems values are IEEE double, but I get rounded float > values by default. > > For example, > $json = ' > { > "results" : [ > { > "elevation" : 1608.637939453125, > "location" : { > "lat" : 39.73915360, > "lng" : -104.98470340 > }, > "resolution" : 4.771975994110107 > }, > { > "elevation" : -50.78903579711914, > "location" : { > "lat" : 36.4555560, > "lng" : -116.8666670 > }, > "resolution" : 19.08790397644043 > } > ], > "status" : "OK" > } > '; > > var_dump(json_decode($json)); > ?> > > object(stdClass)#5 (2) { > ["results"]=> > array(2) { > [0]=> > object(stdClass)#1 (3) { > ["elevation"]=> > float(1608.6379394531) > ["location"]=> > object(stdClass)#2 (2) { > ["lat"]=> > float(39.7391536) > ["lng"]=> > float(-104.9847034) > } > ["resolution"]=> > float(4.7719759941101) > } > [1]=> > object(stdClass)#3 (3) { > ["elevation"]=> > float(-50.789035797119) > ["location"]=> > object(stdClass)#4 (2) { > ["lat"]=> > float(36.455556) > ["lng"]=> > float(-116.866667) > } > ["resolution"]=> > float(19.08790397644) > } > } > ["status"]=> > string(2) "OK" > } > > > json_decode()/json_encode() must be able to handle precise IEEE double > value by _default_. > > serialize() is changed to use max precision. json_decode/encode should do > the same at least. > > I think this change should be provided as bug fix. > Any comments? > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net > --001a113bcfa0dbd66a051bba7cd9--