php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #76005 Ability to specify indentation string for json_encode with JSON_PRETTY_PRINT
Submitted: 2018-02-24 19:16 UTC Modified: 2018-06-05 11:11 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: cmanley at xs4all dot nl Assigned:
Status: Open Package: JSON related
PHP Version: Next Minor Version OS: all
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2018-02-24 19:16 UTC] cmanley at xs4all dot nl
Description:
------------
The indentation string is currently hard coded as can be seen here:
https://github.com/php/php-src/blob/master/ext/json/json_encoder.c#L86

It'd be nicer for users to be able to specify what they want to use for indentation, e.g. more or less spaces or tabs.

To achieve this, a 4th optional parameter will need to be added to json_encode (as it must not be a global setting), or a built in JSON encoder class can be created in which extra features such as indentation can be set per instance.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-06-05 11:11 UTC] bukka@php.net
-Package: json +Package: JSON related
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Fri Sep 21 20:01:25 2018 UTC