Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:48366 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64851 invoked from network); 20 May 2010 20:32:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 May 2010 20:32:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=ilia@prohost.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=ilia@prohost.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain prohost.org from 209.85.212.42 cause and error) X-PHP-List-Original-Sender: ilia@prohost.org X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:36995] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 02/75-45208-A5C95FB4 for ; Thu, 20 May 2010 16:32:27 -0400 Received: by vws7 with SMTP id 7so256640vws.29 for ; Thu, 20 May 2010 13:32:23 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.61.11 with SMTP id r11mr442270vch.134.1274387542903; Thu, 20 May 2010 13:32:22 -0700 (PDT) Received: by 10.220.70.148 with HTTP; Thu, 20 May 2010 13:32:22 -0700 (PDT) In-Reply-To: <7A.44.45208.19295FB4@pb1.pair.com> References: <7A.44.45208.19295FB4@pb1.pair.com> Date: Thu, 20 May 2010 16:32:22 -0400 Message-ID: To: Sara Golemon Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=e0cb4e88756dcd1fb004870c787d Subject: Re: [PHP-DEV] json_decode() and integers larger than LONG_MAX (2^31 - 1) From: ilia@prohost.org (Ilia Alshanetsky) --e0cb4e88756dcd1fb004870c787d Content-Type: text/plain; charset=ISO-8859-1 Sara, Could you not treat a very large integer as a double? We do that in a few areas of the code already. On Thu, May 20, 2010 at 3:50 PM, Sara Golemon wrote: > I know this issue has been seen before, but I hope to do something about > it. > > $json = '1234567890123456789'; > $x = json_decode($json); > /* $x is now a float *aproximately* > * equal to the original value > */ > > For database indexes, being off by one can be disasterous for application > flow, so I'd like to include the option to decode very large integers as > strings. > > To that end, I propose a change in json_decode()'s signature to add an > optional fourth argument, mirroring json_encode()'s second argument: > > mixed json_decode(string $json[, bool $assoc = false[, int $depth = 512[, > int $options]]]); > > Where $options is a bitmask of zero or more of the following: > > JSON_BIGINT_STRING - Store large integers as their original string value > > With the corresponding simple changes in json.c and JSON_parser.c > > If noone objects or offers comments, I'll implement this. > > -Sara > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --e0cb4e88756dcd1fb004870c787d--