News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Enrico Zimuel's Blog:
XML to JSON in PHP an odyssey
May 03, 2011 @ 12:05:09

Enrico Zimuel as a new post to his blog today talking about his exploration of a Zend Framework bug related to the JSON handling of the Zend_Json component. The issue was related to the conversion of XML to JSON but it only happened in specific instances.

As you can see the bar value, of the a element [in the example code], is not represented in JSON. This issue comes also with other XML documents, and in general when an XML node has a single character data child, any attributes are lost.

In tracking down the issue, he followed a lead through a possible SimpleXML issue and, with some further testing, found a simple, non-Zend Framework script to behave the same way. It dropped the "bar" value of the example XML from the object's return value. To get around this bug, he created a new conversion algorithm that redefined the _processXML method in Zend_Json to work with the Zend_Json_Expr functionality to parse things more correctly. If you can't wait for the next release to get it into your codebase, you can grab the code from his post.

0 comments voice your opinion now!
zendframework xml json simplexml custom


blog comments powered by Disqus

Similar Posts

Ralph Schindler's Blog: Composite Rowsets For Many-To-Many Relationships Via Zend_Db_Table

Matthew Weier O'Phinney's Blog: Proper Layer files when using Dojo with Zend Framework

Debuggable Blog: How to bend Cake's Model::find() method to your needs

Padraic Brady's Blog: Contributing To Zend Framework 2.0 Is Free! Hurry Before This Offer Ends!

Chris Hartjes: Testing Listeners


Community Events





Don't see your event here?
Let us know!


series podcast language zendserver release symfony tips threedevsandamaybe deployment laravel list community code framework api bugfix interview introduction conference development

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework