Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:48365 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60109 invoked from network); 20 May 2010 19:58:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 May 2010 19:58:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-wy0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:43972] helo=mail-wy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CC/A4-45208-E7495FB4 for ; Thu, 20 May 2010 15:58:55 -0400 Received: by wyb40 with SMTP id 40so160554wyb.29 for ; Thu, 20 May 2010 12:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=rqiWSdQaSC2jJPZwB/PQ+jY21NebbOJfRGyoRcJrgOI=; b=Lgv3q9nOVWKwL+Epdq4AXIt2YJ4kWhzDTdQX5tGcitzLGC8HvDUerqzObKQJHhfM2M TQZ6twTBTGGOyewKcl4+XE+G3PSQj6LCXvrEQeqVWDJs4z9K9LGq0Xm6qTjoxBSEvp8t WxYOkL6PfxvT5HMlZz3XeXx5g/s08cqk8NJF0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=NKQ6FQfZWIoCtY6E7R/godBgkFl7zm8NjdkwnZwKrgOxdW0rnxVCfhseH62etqODC1 m3bvlMzpD/vQJ4bkjbHVaI4opR/iJfKCKOgJvZUB/2UX5WjyIWexlHgkweQljJy7JTgJ XiyoobSeXaPSDBSWkUsplywzcBKoGk6jDhm7Q= MIME-Version: 1.0 Received: by 10.216.89.11 with SMTP id b11mr238452wef.32.1274385532149; Thu, 20 May 2010 12:58:52 -0700 (PDT) Received: by 10.216.177.146 with HTTP; Thu, 20 May 2010 12:58:52 -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 21:58:52 +0200 Message-ID: To: Sara Golemon Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] json_decode() and integers larger than LONG_MAX (2^31 - 1) From: pierre.php@gmail.com (Pierre Joye) hi Sara, The idea sounds sane, until we have big integer support :) Only one thing, I would suggest to use JSON_BIGINT_AS_STRING instead, more clear about its effect. Cheers, On Thu, May 20, 2010 at 9:50 PM, Sara Golemon wrote: > I know this issue has been seen before, but I hope to do something about = it. > > $json =3D '1234567890123456789'; > $x =3D json_decode($json); > /* $x is now a float *aproximately* > =A0* equal to the original value > =A0*/ > > 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 =3D false[, int $depth =3D 5= 12[, > 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 > > --=20 Pierre @pierrejoye | http://blog.thepimp.net | http://www.libgd.org