{"id":26,"date":"2011-10-11T16:00:51","date_gmt":"2011-10-11T16:00:51","guid":{"rendered":"http:\/\/www.w3.org\/community\/native-web-apps\/?p=26"},"modified":"2011-10-14T08:16:49","modified_gmt":"2011-10-14T08:16:49","slug":"misconception-json-is-easier-than-xml","status":"publish","type":"post","link":"https:\/\/www.w3.org\/community\/native-web-apps\/2011\/10\/11\/misconception-json-is-easier-than-xml\/","title":{"rendered":"Misconception: JSON is easier than XML"},"content":{"rendered":"<p>Another <a href=\"http:\/\/www.brucelawson.co.uk\/2011\/installable-web-apps-and-interoperability\/#comment-769679\" target=\"_blank\" rel=\"nofollow\">misconception<\/a> about Widgets revolves around the choice to use XML over the now <em>in vogue<\/em> <a href=\"http:\/\/www.json.org\/\" target=\"_blank\" rel=\"nofollow\">JSON format<\/a>.<\/p>\n<p><a href=\"http:\/\/hsivonen.iki.fi\/\" target=\"_blank\" rel=\"nofollow\">Proponents of JSON<\/a> <a href=\"http:\/\/www.brucelawson.co.uk\/2011\/installable-web-apps-and-interoperability\/#comment-769679\" target=\"_blank\" rel=\"nofollow\">argue<\/a> that <a href=\"http:\/\/www.w3.org\/XML\/\">XML<\/a> is too complicated for developers and for implementers, while other more <a href=\"http:\/\/groups.google.com\/group\/mozilla.dev.platform\/msg\/53779779c5143c8e\" target=\"_blank\" rel=\"nofollow\">conspiratorial individuals<\/a> claim that there is a &#8220;<a href=\"http:\/\/krijnhoetmer.nl\/irc-logs\/whatwg\/20110624\" target=\"_blank\" rel=\"nofollow\">W3C strategy tax<\/a>&#8221; at work. Proponents of this misconception ignore the fact that JSON can also easily be abused to make overly complicated data structures (see British museum&#8217;s <a href=\"http:\/\/collection.britishmuseum.org\/\" target=\"_blank\" rel=\"nofollow\">near criminal use of JSON<\/a>), and has a lot of restrictions that mirror XML\u2019s complexity in many ways (e.g., JSON also needs to be \u201cwell-formed\u201d and valid, some characters are reserved, only certain data types can be used, etc.).<\/p>\n<p>Having said that, I personally can agree that XML, when used badly (e.g., <a href=\"http:\/\/www.w3.org\/2004\/OWL\/\">RDF\/OWL<\/a>, <a href=\"http:\/\/www.w3.org\/XML\/Schema\">XML Schema<\/a>, <a href=\"http:\/\/en.wikipedia.org\/wiki\/XACML\" target=\"_blank\" rel=\"nofollow\">XACML<\/a>) can overwhelm authors to the point of wanting to rip one\u2019s eyes out. But, the use of XML in Widgets has never been proven to be an issue for Widget developers. This is because the Working Group was well aware of authoring issues with XML authoring and so the configuration document was designed to be as simple as possible to author: the document format is mostly flat in structure, taking away most authoring complexity found in XML. In other words, we knew \u201cthe tools won\u2019t save us\u201d: so we designed everything assuming it would be written by hand.<\/p>\n<p>Further, to make Widget\u2019s use of XML as developer-friendly as possible, the Widget packaging specification provides a <a href=\"http:\/\/www.w3.org\/TR\/2011\/REC-widgets-20110927\/#step-7-process-the-configuration-document\">meticulously defined XML processing model<\/a>, which handles error conditions gracefully, provide sensible defaults and fallback, and only halts processing in the most extreme of cases.<\/p>\n<p>The <a href=\"http:\/\/www.w3.org\/TR\/2011\/REC-widgets-20110927\/#step-7-process-the-configuration-document\">processing model<\/a>, which draws heavily from HTML Standard\u2019s processing model, is also designed to be future proof: allowing the format to be easily expanded as needed through either proprietary extensions or through new W3C specifications.<\/p>\n<p>The choice to use XML for W3C Widgets was for legacy reasons: all the Widget runtimes from when we first started the widget standardization effort were using XML.<\/p>\n<p>The logic of the Working Group at the time was that if we used XML, then it would be easier for implementers to adapt their runtime and developer tools to use the XML W3C Widget format, and it would make it easier for existing content to be migrated to the XML W3C Widget format. Furthermore, when we started this effort in 2006, JSON was just appearing on the scene so it was not as popular a format as it is today (5 years on at the time of writing).<\/p>\n<p>So, although we could have chosen to go against the grain in 2006 and used JSON, the parsing and error-handling models needed for either format would have been essentially identical: i.e., there is still little reason to choose one over the other, and choice of XML has helped other groups use the format for their own purposes (e.g., WAC defines a few additions to the format through their own namespace). If the industry moves towards Google\u2019s and Mozilla\u2019s use of a JSON format for packaged client-side Web applications, a new parsing model specifically for JSON will need to be standardized. This is not a big deal; it just needs to be written down by someone (and no one has found time to do that yet).<\/p>\n<p>Regarding the mythical &#8220;W3C strategy tax&#8221;,\u00a0certain individuals seem convinced that the W3C\u2019s membership has some evil\u00a0conspiracy to push XML on the World and seem convinced that W3C widgets are part of that conspiracy. As much as I would love to be part of some evil conspiracy (and get a few kick-backs from this \u201cstrategy tax\u201d), there is no such conspiracy to my knowledge (and last I checked, I\u2019m still broke but happy to\u00a0receive\u00a0kick-backs;)).<\/p>\n<p>In spite of all this, I&#8217;m would still be happy to help standardize a JSON flavour of the widget configuration document format.<\/p>\n<p>Other posts in this series:<\/p>\n<ul>\n<li><a href=\"http:\/\/www.w3.org\/community\/native-web-apps\/2011\/10\/10\/misconception-widgets-reinvent-the-wheel\/\">Misconception: Widgets reinvent the wheel<\/a><\/li>\n<li><a href=\"http:\/\/www.w3.org\/community\/native-web-apps\/2011\/10\/12\/32\/\">Misconception: XML Digital Signatures is too hard to implement<\/a><\/li>\n<li><a href=\"http:\/\/www.w3.org\/community\/native-web-apps\/2011\/10\/13\/misconception-widgets-lack-an-origin\/\">Misconception: Widgets lack an origin<\/a><\/li>\n<li><a href=\"http:\/\/www.w3.org\/community\/native-web-apps\/2011\/10\/13\/misconception-widgets-lack-a-security-model\/\">Misconception: Widgets lack a security model<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Another misconception about Widgets revolves around the choice to use XML over the now in vogue JSON format. Proponents of JSON argue that XML is too complicated for developers and for implementers, while other more conspiratorial individuals claim that there &hellip; <a href=\"https:\/\/www.w3.org\/community\/native-web-apps\/2011\/10\/11\/misconception-json-is-easier-than-xml\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":233,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_s2mail":"","footnotes":""},"categories":[6],"tags":[5],"class_list":["post-26","post","type-post","status-publish","format-standard","hentry","category-w3cwidgets","tag-w3c-widgets"],"_links":{"self":[{"href":"https:\/\/www.w3.org\/community\/native-web-apps\/wp-json\/wp\/v2\/posts\/26","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.w3.org\/community\/native-web-apps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.w3.org\/community\/native-web-apps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.w3.org\/community\/native-web-apps\/wp-json\/wp\/v2\/users\/233"}],"replies":[{"embeddable":true,"href":"https:\/\/www.w3.org\/community\/native-web-apps\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":10,"href":"https:\/\/www.w3.org\/community\/native-web-apps\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"predecessor-version":[{"id":84,"href":"https:\/\/www.w3.org\/community\/native-web-apps\/wp-json\/wp\/v2\/posts\/26\/revisions\/84"}],"wp:attachment":[{"href":"https:\/\/www.w3.org\/community\/native-web-apps\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.w3.org\/community\/native-web-apps\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.w3.org\/community\/native-web-apps\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}