Req #79189 [Com]: json_encode with JSON_NUMERIC_CHECK and extra option

From: Date: Mon, 09 Aug 2021 06:49:00 +0000
Subject: Req #79189 [Com]: json_encode with JSON_NUMERIC_CHECK and extra option
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235692@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79189&edit=1 ID: 79189 Comment by: ijstartcanonxx at gmail dot com Reported by: dalius dot ulevicius at gmail dot com Summary: json_encode with JSON_NUMERIC_CHECK and extra option Status: Open Type: Feature/Change Request Package: JSON related Operating System: Ubuntu PHP Version: 7.4.2 Block user comment: N Private report: N New Comment: Here Also I Want to tell you something about canon ij setup printer installing into the computer and it has sufficient ink and we get the high print out. We offer online technical support administration to fix printer administration on Canon web. Here you can learn how to set up a printer in easy steps and set up a new Canon printer by following this step.https://ijstartcannonx.com/ Previous Comments: ------------------------------------------------------------------------ [2020-01-29 09:32:56] dalius dot ulevicius at gmail dot com Description: ------------ JSON_NUMERIC_CHECK does not respect the definition of numbers. I think will be great to add extra option like (JSON_NUMERIC_LEADZERO), to do not trailing zeros at the lead. Extra reported as a bug many years ago: https://bugs.php.net/bug.php?id=70680 Test script: --------------- print_r(json_encode(array("shouldBeString0123456" => "0123456", "shouldBeString+0123456" => "+0123456", "isInt" => "123456"), JSON_NUMERIC_CHECK | JSON_NUMERIC_LEADZERO)); Expected result: ---------------- { "shouldBeString0123456":"0123456", "shouldBeString+0123456":"+0123456", "isInt":123456 } Actual result: -------------- { "shouldBeString0123456":123456, // Bad with JSON_NUMERIC_CHECK "shouldBeString+0123456":123456, // Bad with JSON_NUMERIC_CHECK "isInt":123456 // Good } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79189&edit=1

« previous php.bugs (#235692) next »