Edit report at https://bugs.php.net/bug.php?id=44331&edit=1

 ID:                 44331
 Comment by:         joined_up_typeski at yahoo dot com
 Reported by:        jeremy at duckwizard dot com
 Summary:            Formatting option for json_encode
 Status:             Closed
 Type:               Feature/Change Request
 Package:            JSON related
 Operating System:   Debian Stable
 PHP Version:        5.2.5
 Assigned To:        aharvey
 Block user comment: N
 Private report:     N

 New Comment:

PHP Version 5.3.5-pl0-gentoo
JSON 1.2.1

passing JSON_PRETTY_PRINT to the function means that I get no output at all 
from PHP.


Previous Comments:
------------------------------------------------------------------------
[2011-04-29 19:11:37] php at mjpa dot co dot uk

This has not been implemented...

------------------------------------------------------------------------
[2010-09-16 18:21:59] ahar...@php.net

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

The trunk version of json_encode() will now accept a JSON_PRETTY_PRINT option.

------------------------------------------------------------------------
[2010-09-16 18:21:17] ahar...@php.net

Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&revision=303425
Log: Implement FR #44331 (Formatting option for json_encode). Bikeshedding 
about the
exact form of the JSON pretty printing and brace handling will only be accepted
in the form of patches. ;)

------------------------------------------------------------------------
[2009-12-08 12:05:52] pankaj dot khairnar at live dot com

yes it will be a real nice feature of json_encode function
and I am expecting it to same.

------------------------------------------------------------------------
[2008-03-04 20:05:37] jeremy at duckwizard dot com

Description:
------------
One of the appeals of JSON is that it is human readable.  However, json_encode 
produces output that is not particularly manageable by a human - little more so 
than PHP's own serialization.  DOM, for example, has a formatOutput option that 
nicely indents the resulting XML.  A similar option for json_encode would be 
extremely helpful.

Reproduce code:
---------------
$obj = new stdClass;
$obj->field1 = "hello";
$obj->field2 = "world";
$obj->field3 = array("key" => "value", "level2" => array(1,2,3));
echo json_encode($obj, JSON::FORMAT_OUTPUT);

//flags are an implementation example

Expected result:
----------------
{
        "field1":"hello",
        "field2":"world",
        "field3":
        {
                "key":"value",
                "level2": [1,2,3]
        }
}

Actual result:
--------------
{"field1":"hello","field2":"world","field3":{"key":"value","level2":[1,2,3]}}


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=44331&edit=1

Reply via email to