|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-12-08 12:05 UTC] pankaj dot khairnar at live dot com
[2010-09-16 18:21 UTC] aharvey@php.net
[2010-09-16 18:21 UTC] aharvey@php.net
-Status: Open
+Status: Closed
-Package: Feature/Change Request
+Package: JSON related
-Assigned To:
+Assigned To: aharvey
[2010-09-16 18:21 UTC] aharvey@php.net
[2011-04-29 19:11 UTC] php at mjpa dot co dot uk
[2011-07-21 09:04 UTC] joined_up_typeski at yahoo dot com
[2011-07-21 11:35 UTC] rasmus@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 03:00:01 2025 UTC |
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]}}