Edit report at https://bugs.php.net/bug.php?id=61537&edit=1
ID: 61537 Comment by: j...@php.net Reported by: j...@php.net Summary: json_encode() incorrectly truncates/discards information Status: Open Type: Bug Package: JSON related Operating System: all PHP Version: 5.4.0 Block user comment: N Private report: N New Comment: Per documentation: Return Values: Returns a JSON encoded string on success or FALSE on failure. Previous Comments: ------------------------------------------------------------------------ [2012-03-28 05:01:01] j...@php.net Description: ------------ When json_encode() cannot correctly encode its argument into JSON, the expected behaviour is that it will return false, and people can check json_last_error() to see why it failed. Currently, it will replace all data it could not encode with the string 'null'. This can lead to what appears to be silently discarding data. Test script: --------------- <?php var_dump(json_encode(chr(215)), json_last_error()); Expected result: ---------------- bool(false) int(5) Actual result: -------------- string(4) 'null' int(5) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61537&edit=1