|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2014-04-14 01:56 UTC] stas@php.net
[2014-04-14 01:56 UTC] stas@php.net
-Status: Open
+Status: Closed
[2014-04-15 12:04 UTC] ab@php.net
[2014-04-15 13:05 UTC] ab@php.net
[2014-05-01 14:59 UTC] tyrael@php.net
[2014-10-07 23:16 UTC] stas@php.net
[2014-10-07 23:27 UTC] stas@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 04:00:02 2025 UTC |
Description: ------------ The JSON_PRETTY_PRINT option to json_encode() causes a blank line to be inserted between the brackets or braces of an empty array or object. This is not how one would write out JSON by hand. Furthermore, it is inconsistent with JavaScript's JSON.stringify() and Python's json.dumps(). I think this may be unintentional because there is no test that shows the author of cb9c8233fc2d (r303425) had considered these cases (and chose not to put the brackets/braces on the same line). I will submit a GitHub pull request shortly to fix this. Test script: --------------- <?php echo json_encode([[],(object)[]], JSON_PRETTY_PRINT), "\n"; Expected result: ---------------- [ [], {} ] Actual result: -------------- [ [ ], { } ]