php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57469 decode chokes on unquoted object keys
Submitted: 2007-01-05 08:43 UTC Modified: 2008-12-18 21:41 UTC
From: jan at horde dot org Assigned:
Status: Not a bug Package: json (PECL)
PHP Version: Irrelevant OS:
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: jan at horde dot org
New email:
PHP Version: OS:

 

 [2007-01-05 08:43 UTC] jan at horde dot org
Description:
------------
json_decode() fails completely on the following code:

Reproduce code:
---------------
var_dump(json_decode('[{0:"tan","model":"sedan"},{"0":"red",model:"sports"}]'));
var_dump(json_decode('{"1":"one",2:"two","5":\'fi"ve\'}'));

Expected result:
----------------
array(2) {
  [0]=>
  object(stdClass)(2) {
    [0]=>
    string(3) "tan"
    ["model"]=>
    string(5) "sedan"
  }
  [1]=>
  object(stdClass)(2) {
    [0]=>
    string(3) "red"
    ["model"]=>
    string(6) "sports"
  }
}
object(stdClass)(3) {
  [1]=>
  string(3) "one"
  [2]=>
  string(3) "two"
  [5]=>
  string(5) "fi"ve"
}


Actual result:
--------------
NULL
NULL

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-18 21:41 UTC] scottmac@php.net
The specification states that all keys are strings and 
therefore must be surrounded by quotes.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 06 05:01:26 2024 UTC