ID:               41976
 Updated by:       [EMAIL PROTECTED]
 Reported By:      stefan dot priebsch at e-novative dot de
-Status:           Open
+Status:           Closed
 Bug Type:         JSON related
 Operating System: WinXP
 PHP Version:      5.2.3
 New Comment:

In latest CVS given proper string casts the code returns the expected:

string(4) "test"
string(6) ""test""
string(4) "test"
string(6) ""test""

output.


Previous Comments:
------------------------------------------------------------------------

[2007-07-18 15:59:55] stefan dot priebsch at e-novative dot de

Ok, the problem: I have a SimpleXML object that I want to convert to
JSON using json_encode(). According to the manual, json_encode() works
on all types.

As soon as there is CDATA in the XML, that very node shows up as "" in
the JSON encoding. Remove the CDATA section, everything works. Thus I
claim that json_encode() does not work properly on CDATA, which I
consider a bug.

------------------------------------------------------------------------

[2007-07-18 08:52:18] [EMAIL PROTECTED]

Don't use such texts for 'Summary'. Please write something that
describes the problem..

------------------------------------------------------------------------

[2007-07-17 19:09:53] stefan dot priebsch at e-novative dot de

Johannes, would you please care to actually *read* and try to
*understand* my bug report before marking it as bogus?

My point is that json_encode() works properly with nested XML, but does
NOT work correctly when the nested XML contains CDATA.

------------------------------------------------------------------------

[2007-07-17 12:36:14] [EMAIL PROTECTED]

$xml and (string)$xml are different things. Using different things as
arguments for a function gives different results.

------------------------------------------------------------------------

[2007-07-17 10:46:38] stefan dot priebsch at e-novative dot de

I re-opened the bug due to the discussion of bug #42001. json_encode()
does not work on nested XML with a string cast, but it does work without
a string cast. (Of course except for the CDATA problem that made me file
this bug in the first place.)

$xml = new SimpleXMLElement('<?xml version="1.0"
encoding="UTF-8"?><test><sub>test</sub><another>value</another><path><to
><tag>something</tag></to></path></test>');
  var_dump(json_encode($xml));
  var_dump(json_encode((string) $xml));

  $xml = new SimpleXMLElement('<?xml version="1.0"
encoding="UTF-8"?><test><sub><![CDATA[test]]></sub><another>value</anoth
er><path><to><tag>something</tag></to></path></test>');
  var_dump(json_encode($xml));
  var_dump(json_encode((string) $xml));

------------------------------------------------------------------------

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
    http://bugs.php.net/41976

-- 
Edit this bug report at http://bugs.php.net/?id=41976&edit=1

Reply via email to