Bug #66027 [NEW]: json_encode returns 'null' string instead of false on error
| From: | vseticka dot martin at gmail dot com | Date: | Sun, 03 Nov 2013 16:31:22 +0000 |
| Subject: | Bug #66027 [NEW]: json_encode returns 'null' string instead of false on error | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-182579@lists.php.net to get a copy of this message | ||
From: vseticka dot martin at gmail dot com
Operating system: Windows
PHP version: 5.4.21
Package: JSON related
Bug Type: Bug
Bug description:json_encode returns 'null' string instead of false on error
Description:
------------
The script shows that json_encode function does not return FALSE on
JSON_ERROR_UTF8 error as stated in manual page
http://php.net/manual/en/function.json-encode.php
but it returns "null"
string.
Test script:
---------------
$result = json_encode(iconv('UTF-8', 'UCS-2', "PÅÃliÅ¡
žluÅ¥ouÄký
kůŠúpÄl Äábelské ódy."));
var_dump(json_last_error());
var_dump($result);
Expected result:
----------------
int(5)
bool(false)
Actual result:
--------------
int(5)
string(4) "null"
--
Edit bug report at https://bugs.php.net/bug.php?id=66027&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66027&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66027&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66027&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66027&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66027&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66027&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66027&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66027&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66027&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66027&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66027&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66027&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66027&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66027&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66027&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66027&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66027&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66027&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66027&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66027&r=mysqlcfg