note 119698 added to function.json-encode
| From: | Nick | Date: | Thu, 04 Aug 2016 13:47:56 +0000 |
| Subject: | note 119698 added to function.json-encode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-206213@lists.php.net to get a copy of this message | ||
Please note that there was an (as of yet) undocumented change to the json_encode() function between
2 versions of PHP with respect to JSON_PRETTY_PRINT:
In version 5.4.21 and earlier, an empty array [] using JSON_PRETTY_PRINT would be rendered as 3
lines, with the 2nd one an empty (indented) line, i.e.:
"data": [
],
In version 5.4.34 and above, an empty array [] using JSON_PRETTY_PRINT would be rendered as exactly
[] at the spot where it occurs, i.e.
"data: [],
This is not mentioned anywhere in the PHP changelist and migration documentations; neither on the
json_encode documentation page.
This is very useful to know when you are parsing the JSON using regular expressions to manually
insert portions of data, as is the case with my current use-case (working with JSON exports of over
several gigabytes requires sub-operations and insertion of data).
----
Server IP: 72.52.91.14
Probable Submitter: 31.151.125.130
----
Manual Page -- http://php.net/manual/en/function.json-encode.php
Edit -- https://master.php.net/note/edit/119698
Del: integrated -- https://master.php.net/note/delete/119698/integrated
Del: useless -- https://master.php.net/note/delete/119698/useless
Del: bad code -- https://master.php.net/note/delete/119698/bad+code
Del: spam -- https://master.php.net/note/delete/119698/spam
Del: non-english -- https://master.php.net/note/delete/119698/non-english
Del: in docs -- https://master.php.net/note/delete/119698/in+docs
Del: other reasons-- https://master.php.net/note/delete/119698
Reject -- https://master.php.net/note/reject/119698
Search -- https://master.php.net/manage/user-notes.php