|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patchesjson_parse_false_number_testing (last revision 2016-02-04 15:39 UTC by arrizaqu at yahoo dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-11-24 18:48 UTC] rasmus@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 20 19:00:01 2025 UTC |
Description: ------------ When parsing a JSON Payload containing integers or floats with leading zeros as values which haven't been escaped using double quotes, json_decode() returns false. Even thought leading zeros are ( most of the times ) irrelevant for integers, the function should at least trim the zeros out and not fail the entire decoding process. JSON returned from some Java JSON generators come with integers containing leading zeros and not escaped by double quotes. Reproduce code: --------------- <?php $payload = <<<payload { "test" : 06 } payload; if(!$obj = json_decode($payload)) die("Problems on JSON Parsing the json_decode() function has returned false"); print_r($obj); Expected result: ---------------- stdClass Object ( [test] => 6 ) Actual result: -------------- Problems on JSON Parsing the json_decode() function has returned false