Don't waste time on XML, json ftw
Don't get convinced by anybody to build an API using XML. All of the XML parsers out there suck. Json has better performace, and is built in seamlessly into PHP and Javascript.
Written by Pasha
Related protips
8 Responses
It's also natively parsed by the browsers and is lighter than XML.
@kanuj Yes, you can directly use it with/in JavaScript and does it so flawlessly, Server-side -> client-side
The main reason you'd want XML is if you need that extra layer of complexity to your data...granted, you can do "attributes" in your json if you structure your data that way.
@baohx2000 The concept of XML is definitely great. BUT, that complexity often ends up being the arch-enemy of designing APIs that are easy to understand and integrate with. 99.9% of implementations simply don't need it. My caution is against programmers who started when XML was the standard (who are now mostly in decision-making "senior" positions) and have failed to stay current on this issue.
I agree completely. Just saying that JSON doesn't have that extra layer of complexity unless you build it into your data structures. For example: "<mytag type='thing' operator='add'><item>3</item><item>4</item></mytag>" would translate to something like: myjson = {type:'thing',operator:'add',items:[3,4]}. So yes, JSON is much simpler. Still, there are pros and cons to both, just like everything else.
XML is an awful model. Unfortunately, we're still stuck with XML floating around out there. @invalidka, you nailed it... it's downright scary when decision makers fall behind on current technology trends.
XML is awful, all the parsers suck and it's painful to implement. JSON on the other side is easy to implement and all the parsers work perfectly.
I wish someone would tell the IDPF, who create the EPUB standard, this. Metadata would be greatly simplified with JSON.