#45878 [Opn->Bgs]: json_encode() bug report
| From: | jani@php.net | Date: | Thu, 21 Aug 2008 20:49:29 +0000 |
| Subject: | #45878 [Opn->Bgs]: json_encode() bug report | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-128298@lists.php.net to get a copy of this message | ||
ID: 45878
Updated by: jani@php.net
Reported By: chenming522 at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: JSON related
Operating System: windows xp
PHP Version: 5.2.6
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
Previous Comments:
------------------------------------------------------------------------
[2008-08-21 06:07:43] chenming522 at gmail dot com
Description:
------------
Hi:
I am a new gur for PHP program, Recently when I write a program that
use php function json_encode() to translate a simpleXML object into json
code, I found the attributes of the XML leafage node was lose.
Wait to solve :).
Thank you.
Reproduce code:
---------------
<?
$xml_str = "<root><node attr='node attribute'>node
value</node></root>";
$xml_obj = simplexml_load_string($xml_str);
$json = json_encode($xml_obj);
echo $json; // so where is node's attribute
echo "\n=======================================\n";
$xml_str = "<root><node attr='node
attribute'></node></root>";
$xml_obj = simplexml_load_string($xml_str);
$json = json_encode($xml_obj);
echo $json; // found it, but why?
?>
Expected result:
----------------
{"node":"node value"}
=======================================
{"node":{"@attributes":{"attr":"node attribute"}}}
Actual result:
--------------
inlude node's value and attributes
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45878&edit=1