Bug #46600 [Com]: "_empty_" key in objects (see #41504)
| From: | matt at mpcm dot com | Date: | Tue, 14 Jan 2014 18:50:41 +0000 |
| Subject: | Bug #46600 [Com]: "_empty_" key in objects (see #41504) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-183791@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=46600&edit=1
ID: 46600
Comment by: matt at mpcm dot com
Reported by: Matt at mpcm dot com
Summary: "_empty_" key in objects (see #41504)
Status: No Feedback
Type: Bug
Package: JSON related
Operating System: *
PHP Version: 5CVS, 6CVS (2008-11-18)
Block user comment: N
Private report: N
New Comment:
Last post was a bad example, this is the actual output:
as object: {"_empty_":"c"}
as array: {"_empty_":"a","":"c"}
Previous Comments:
------------------------------------------------------------------------
[2014-01-14 18:48:23] matt at mpcm dot com
With an output of:
as object: {"_empty_":"c"}
as array: {"_empty_":"b","":"c"}
------------------------------------------------------------------------
[2014-01-14 18:47:27] matt at mpcm dot com
To illustrate the current collision state, as this came up on the JSMentors list recently.
<?php
$a =
'{"_empty_":"a","":"b","":"c"}';
echo "as object: " . json_encode(json_decode($a));
echo "\n";
echo "as array: " . json_encode(json_decode($a, true));
PHP 5.4.17 (cli) (built: Aug 25 2013 02:03:38)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
------------------------------------------------------------------------
[2009-08-12 22:49:59] scottmac@php.net
Works for me here with 5.2-dev and 5.3-dev
object(stdClass)#1 (2) {
["test2"]=>
int(5)
["_empty_"]=>
int(6)
}
------------------------------------------------------------------------
[2009-08-12 21:20:22] michaeldnelson dot mdn at gmail dot com
I am using freebsd 7.2 and php 5.2.10 the first test case
var_dump(json_decode('{"":"test"}'));
silently stops processing of the script
The test case
var_dump(json_decode('{"test2":5,"":6}'));
Fatal error: Cannot access empty property
I am not sure the second is expected behavior but considering json is often from feeds it would be
nice to fail more gracefully.
------------------------------------------------------------------------
[2008-12-26 01:00:01] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=46600
--
Edit this bug report at https://bugs.php.net/bug.php?id=46600&edit=1