Is JSON the Developer's Choice?

Once upon a time there was the great debate over JSON vs XML. The past few years have seen JSONs popularity rise despite XML (and other formats) being well-established. Our own statistics on ProgrammableWeb show a significant increase in the number of JSON APIs over 2009/2010. During 2009 there were only 191 JSON APIs registered. So far in 2010 there are already 223!

But the increase in JSON APIs doesn't appear to be at the cost of XML APIs. Undoubtedly some providers are setting a preference of one data format over another, but it seems the greater majority are simply making their data available in both formats, especially as many application frameworks make this a fairly painless task.

This is good news for us seasoned developers as we have more choice. For newer developers though, choice can be more of a hindrance than a help. Even for more advanced programmers, the question of which format to use can be a tricky one to answer.

Tweet from @schleyfox clearly a bit scared of XML APIs

It seems that many developers are choosing JSON based on its apparent syntactic simplicity when compared to XML. Others seem to base their choice on the medium of consumption e.g. a server-side language or JavaScript in the browser. Still others would quote perceived performance issues.

I prefer JSON for client-side Javascript use. This is purely and simply convenience because once decoded/parsed my data is addressable in standard notation and I don't have to write too many extra variable declarations and Function calls to extract the data.

However, I think David Megginson put it most succinctly:

"Personally, I like XML because it’s familiar and has a lot of tool support, but I could easily (and happily) build an application based on any of [them] — after all, once I stare long enough, they all look the same to me."

All said and done, it seems as though personal preference, context and the needs of the application are the most important factors in determining which format to use. Ultimately, though, isn't it the data that's most important?

Which format do you prefer to consume and why? If you're building APIs, what challenges are you facing making data available in both formats? Let us know in the comments!

Be sure to read the next Best Practices article: Web API Documentation Best Practices