Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:48364 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58158 invoked from network); 20 May 2010 19:50:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 May 2010 19:50:42 -0000 X-Host-Fingerprint: 24.23.200.139 c-24-23-200-139.hsd1.ca.comcast.net Received: from [24.23.200.139] ([24.23.200.139:21272] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7A/44-45208-19295FB4 for ; Thu, 20 May 2010 15:50:41 -0400 Message-ID: <7A.44.45208.19295FB4@pb1.pair.com> To: internals@lists.php.net Date: Thu, 20 May 2010 12:50:37 -0700 User-Agent: Thunderbird 2.0.0.21 (Macintosh/20090302) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 24.23.200.139 Subject: json_decode() and integers larger than LONG_MAX (2^31 - 1) From: pollita@php.net (Sara Golemon) 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