Doc #67469 [NEW]: json_encode changed behaviour in 5.5

From: Date: Wed, 18 Jun 2014 20:06:34 +0000
Subject: Doc #67469 [NEW]: json_encode changed behaviour in 5.5
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-11289@lists.php.net to get a copy of this message
From:             martin at ringehahn dot de
Operating system: 
PHP version:      5.5.13
Package:          JSON related
Bug Type:         Documentation Problem
Bug description:json_encode changed behaviour in 5.5

Description:
------------
It appears that in 5.5, "#61537 json_encode() incorrectly
truncates/discards information" has been addressed. php 5.4 and 5.3 also
had this patch at some point but it was reverted later. I assume this
was done for not breaking backcompat in point releases.

However, the php 5.5 Changelog fails to mentioned that json_encode
changed behaviour and now behaves as documented. specifically: "Returns
a JSON encoded string on success or FALSE on failure."

the documentation also fails to mention the new constant
JSON_PARTIAL_OUTPUT_ON_ERROR. well, it actually mentions it by
referencing to it but it is not listed as a proper item.

Test script:
---------------
echo json_encode(["foo" => chr(132), "bar" => "bar"]);
// nothing, false
// this used to return "Expected result"

Expected result:
----------------
since the Changelog does not mention anything json-related, I'd expect
the same behaviour as in previous versions:

echo json_encode(["foo" => chr(132), "bar" => "bar"]);
PHP Warning:  json_encode(): Invalid UTF-8 sequence in argument in php
shell code on line 1
{"foo":null,"bar":"bar"}

Actual result:
--------------
false

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



Thread (6 messages)

« previous php.doc.bugs (#11289) next »