|  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
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:
Solve the problem:
37 - 16 = ?
Subscribe to this entry?

 [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: Sun Dec 10 15:01:27 2023 UTC