php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66027 json_encode returns 'null' string instead of false on error
Submitted: 2013-11-03 16:31 UTC Modified: 2013-11-03 17:19 UTC
From: vseticka dot martin at gmail dot com Assigned: nikic (profile)
Status: Closed Package: JSON related
PHP Version: 5.4.21 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
25 - 13 = ?
Subscribe to this entry?

 
 [2013-11-03 16:31 UTC] vseticka dot martin at gmail dot com
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"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-11-03 17:19 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2013-11-03 17:19 UTC] nikic@php.net
Has already been fixed in 5.5
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Sep 28 20:03:36 2021 UTC