I'm manipulating few data with PHP, I have the choice between Json and XML. But I don't know what to choose, I never worked with one of them. So I want the easiest one.
Also I wonder if there's good classes that can make parsing (XML or Json) easier.
I focus mainly on ease of use rather than speed and scale.
JSON is simpler than XML, but XML is more powerful. For common applications, JSON's terse semantics result in code that is easier to follow. For applications with complex requirements surrounding data interchange, such as in enterprise, the powerful features of XML can significantly reduce software risk.
In any case, if a project requires document markup and metadata information, it is better to use XML. Otherwise, for a more organized data interchange, JSON could be your preferred choice.
JSON does not provide namespace support while XML provides namespaces support. JSON has no display capabilities whereas XML offers the capability to display data. JSON is less secured whereas XML is more secure compared to JSON. JSON supports only UTF-8 encoding whereas XML supports various encoding formats.
XML still lives today, mainly because it is platform agnostic. It supports Unicode and is often used as part of a data presentation workflow.
json.org makes JSON parsing simple. SimpleXML makes XML simple for PHP.
When choosing which one, it really depends on your application. If you will be passing data to JavaScript for processing on the client-side, then I recommend JSON. IMO, XML is better for data interchange between systems because it is very well understood and human readable (making interpreting easier for you). JSON is smaller over the wire, as there are no closing tags.
JSON parsing and generating is natively included in php: http://www.php.net/json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With