|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patchesphp-5.3.8-json_numeric_check-fix.patch (last revision 2011-08-31 01:23 UTC by dchurch at sciencelogic dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-10-17 23:51 UTC] iliaa@php.net
[2011-10-17 23:51 UTC] iliaa@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: iliaa
[2011-10-17 23:51 UTC] iliaa@php.net
[2012-04-18 09:48 UTC] laruence@php.net
[2012-07-24 23:39 UTC] rasmus@php.net
[2013-11-17 09:35 UTC] laruence@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 12:00:01 2025 UTC |
Description: ------------ When JSON_NUMERIC_CHECK is used with json_encode, it looks at every string that is printed, including for property names, and checks whether to display it as an integer instead. However, JSON mandates that all property names be represented as double-quoted strings, and displaying them as integers violates the spec. The attached patch (against the php-5.3.8 tarball, should apply cleanly against SVN 5.3 branch) fixes this by masking out the JSON_NUMERIC_CHECK flag while outputting string properties. Test script: --------------- $output = (object)array(); $output->{"1"} = "5"; echo json_encode($output, JSON_NUMERIC_CHECK); Expected result: ---------------- {"1":5} Actual result: -------------- {1:5}