Bug #68231 [Opn->Nab]: Unexpected identifier in the json_decode

From: Date: Wed, 15 Oct 2014 16:56:00 +0000
Subject: Bug #68231 [Opn->Nab]: Unexpected identifier in the json_decode
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188114@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68231&edit=1 ID: 68231 Updated by: nikic@php.net Reported by: armin390 at gmail dot com Summary: Unexpected identifier in the json_decode -Status: Open +Status: Not a bug Type: Bug Package: JSON related Operating System: Debian sid PHP Version: 5.6.1 Block user comment: N Private report: N New Comment: "test-me+for" is a valid property name in PHP. You can access it using $obj->{"test-me+for"}. Previous Comments: ------------------------------------------------------------------------ [2014-10-15 09:38:42] 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" } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68231&edit=1

« previous php.bugs (#188114) next »