|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73254 Incorrect indentation generated by json_encode() with JSON_PRETTY_PRINT
Submitted: 2016-10-05 23:28 UTC Modified: 2016-10-30 13:29 UTC
From: robo006 at gmail dot com Assigned: bukka (profile)
Status: Closed Package: JSON related
PHP Version: 7.1.0RC3 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: robo006 at gmail dot com
New email:
PHP Version: OS:


 [2016-10-05 23:28 UTC] robo006 at gmail dot com
After call `json_encode()` that fails, all future `json_encode()` calls with `JSON_PRETTY_PRINT` generates output with incorrect indentation. 



Test script:

echo json_encode([json_encode([1], JSON_PRETTY_PRINT)]), "\n";

$fp = fopen('php://stdin', 'r');
$data = ['a' => $fp];
echo json_encode($data), "\n";

echo json_encode([json_encode([1], JSON_PRETTY_PRINT)]), "\n";

Expected result:
["[\n    1\n]"]

["[\n    1\n]"]

Actual result:
["[\n    1\n]"]

["[\n        1\n    ]"]


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-06 18:58 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: bukka
 [2016-10-30 13:29 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Feb 27 21:01:27 2024 UTC