xii0jg
Last Updated: February 25, 2016
·
1.643K
· invalidka

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.

8 Responses
Add your response

129

It's also natively parsed by the browsers and is lighter than XML.

over 1 year ago ·
1164

@kanuj Yes, you can directly use it with/in JavaScript and does it so flawlessly, Server-side -> client-side

over 1 year ago ·
2074

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.

over 1 year ago ·
2105

@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.

over 1 year ago ·
2137

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.

over 1 year ago ·
3978

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.

over 1 year ago ·
3979

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.

over 1 year ago ·
6507

I wish someone would tell the IDPF, who create the EPUB standard, this. Metadata would be greatly simplified with JSON.

over 1 year ago ·