ID: 42708 Updated by: [EMAIL PROTECTED] Reported By: tjerk dot meesters at muvee dot com -Status: Open +Status: Wont fix Bug Type: JSON related Operating System: * PHP Version: 5.2.4 New Comment:
1. "Fixing" this would violate the JSON spec. HEAD (aka PHP 6) also behaves the same way now as other branches. 2. NULL is returned whenever you pass invalid data to json_decode(). Previous Comments: ------------------------------------------------------------------------ [2007-11-23 00:45:20] [EMAIL PROTECTED] php5.3-200711221930: string(22) "Sir, you\'re an idiot!" NULL -- php6.0-200711202130: string(22) "Sir, you\'re an idiot!" string(26) "["Sir, you\'re an idiot!"]" ------------------------------------------------------------------------ [2007-09-19 10:19:22] tjerk dot meesters at muvee dot com Description: ------------ When a single quote is being escaped, the json_decode() gives some unexpected results. 1. According to the JSON specs, the single quote is not in the list of characters that can follow the escape character (such as n, t, b, r, etc.); however, JavaScript does recognize the single quote so it would be very nice to have as a feature. 2. When wrapping a string with an escaped single quote inside an array context, the json_decode() gives up and returns NULL. Reproduce code: --------------- <?php $s = '"Sir, you\\\'re an idiot!"'; var_dump(json_decode($s)); var_dump(json_decode("[$s]")); ?> Expected result: ---------------- string(21) "Sir, you're an idiot!" array(1) { [0]=> string(21) "Sir, you're an idiot!" } Actual result: -------------- string(22) "Sir, you\'re an idiot!" NULL ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42708&edit=1