Monday, February 1, 2010

A New Format for JSON Results

It's been two and a half years since we announced JSON as an alternative output format to Atom XML for YouTube API responses. As illustrated in the developer's guide and codelab, JSON-formatted data is a natural choice when writing web applications – after all, who wants to parse XML from JavaScript?

Our existing JSON format isn't perfect, however. It's very much a literal translation from Atom. As is often the case with literal translations, the current JSON format is wordier than it needs to be, and it lacks some of the elegance that a native dialect would offer.

We've rethought out current JSON implementation, and moved away from a literal representation of the Atom data to a format that we hope will be more pleasing to those who are fluent in JSON. The vestigial XML namespace prefixes are no more, and we've removed many pieces of metadata specific to Atom documents that come across as noise in JSON. Repeating data elements are always structured as true JSON lists, and useful video metadata that exist as XML attributes in Atom have been rearranged to make more sense in the JSON document. You'll also find that the new JSON results are more compact than Atom XML, which is of special importance to code running from limited-bandwith mobile applications.

We call this new format JSON-C, and you can read about all the technical details in our documentation and see it in action in our live demo.

With the release of JSON-C, we consider the legacy JSON format officially deprecated. All new development should prefer JSON-C to JSON, and if you have existing YouTube API code that relies on JSON-formatted results, you'll need to upgrade your code to use the new format. We will be supporting legacy JSON-formatted output in accordance with the deprecation policy outlined in our Terms of Service.

Cheers,
-Jeff Posnick, YouTube API Team