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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: vseticka dot martin at gmail dot com
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 00:01:28 2024 UTC