php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68231 Unexpected identifier in the json_decode
Submitted: 2014-10-15 09:38 UTC Modified: 2014-10-15 16:56 UTC
From: armin390 at gmail dot com Assigned:
Status: Not a bug Package: JSON related
PHP Version: 5.6.1 OS: Debian sid
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: armin390 at gmail dot com
New email:
PHP Version: OS:

 

 [2014-10-15 09:38 UTC] armin390 at gmail dot com
Description:
------------
When I try to decode a json string that include a key with identifiers,then it will be converted to an invalid propery name.

Test script:
---------------
<?php
$string = '{"test-me+for": "X"}';
var_dump(json_decode($string)); 

Expected result:
----------------
Fatal error: syntax error, unexpected ...

Actual result:
--------------
object(stdClass)#1 (1) { ["test-me+for"]=> string(1) "X" }

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-15 16:56 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2014-10-15 16:56 UTC] nikic@php.net
"test-me+for" is a valid property name in PHP. You can access it using $obj->{"test-me+for"}.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Dec 07 11:01:24 2019 UTC