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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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 Dec 22 01:01:30 2024 UTC