|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65616 json_decode now allows single quoted keys
Submitted: 2013-09-04 15:34 UTC Modified: 2013-09-04 16:04 UTC
From: glenjamin at gmail dot com Assigned: remi (profile)
Status: Closed Package: JSON related
PHP Version: 5.5.3 OS: CentOS
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.
Block user comment
Status: Assign to:
Bug Type:
From: glenjamin at gmail dot com
New email:
PHP Version: OS:


 [2013-09-04 15:34 UTC] glenjamin at gmail dot com
It appears that json_decode is less strict in newer versions of PHP, and allows object keys to be single quoted.

Test script:
$ php -v
PHP 5.5.3 (cli) (built: Aug 21 2013 17:57:15)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

$ php -r "var_dump(json_decode(\"{'a':1}\"));"
class stdClass#1 (1) {
  public $a =>

Expected result:
json_decode should return NULL and make the error available through json_last_error()

Actual result:
The string is parsed into an object


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-09-04 15:58 UTC]
-Assigned To: +Assigned To: remi
 [2013-09-04 15:58 UTC]
Sounds like a json-c bug.
 [2013-09-04 16:03 UTC]
This is a json-c regression already fixed in upcoming version 1.3.2
 [2013-09-04 16:04 UTC]
-Status: Assigned +Status: Closed
 [2013-09-04 16:04 UTC]
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 04:01:28 2024 UTC