|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78515 JSON_THROW_ON_ERROR doesn't throw an exception
Submitted: 2019-09-09 10:13 UTC Modified: 2019-09-09 10:26 UTC
From: nick dot kdevil at gmail dot com Assigned:
Status: Not a bug Package: JSON related
PHP Version: 7.3.9 OS: Linux
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: nick dot kdevil at gmail dot com
New email:
PHP Version: OS:


 [2019-09-09 10:13 UTC] nick dot kdevil at gmail dot com
I was under the impression, that if i have a json_last_error, that if the flag JSON_THROW_ON_ERROR is set, i will get an exception. In the example below json_last_error would return 4, but no exception is thrown.

Test script:

Expected result:
The appropriate exception is thrown

Actual result:
NULL is being returned


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-09-09 10:15 UTC]
-Status: Open +Status: Not a bug
 [2019-09-09 10:15 UTC]
Please see the function signature at You are passing the flag to the $depth parameter, not the $options parameter.
 [2019-09-09 10:18 UTC] nick dot kdevil at gmail dot com
the embarassment is real :/
thx nikic
 [2019-09-09 10:26 UTC] nick dot kdevil at gmail dot com
@nikic while this is totally due to my own stupidity, i see where i went wrong

while encode has options first, then depth
decode has depth first, then options

maybe it would be worth aligning this?
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Dec 09 10:01:28 2023 UTC