{"id":219,"date":"2006-01-31T07:48:38","date_gmt":"2006-01-31T13:48:38","guid":{"rendered":"http:\/\/blog.codedread.com\/?p=219"},"modified":"2006-01-31T07:48:38","modified_gmt":"2006-01-31T13:48:38","slug":"json-feeds","status":"publish","type":"post","link":"https:\/\/www.codedread.com\/blog\/archives\/2006\/01\/31\/json-feeds\/","title":{"rendered":"JSON feeds"},"content":{"rendered":"<p><a href=\"http:\/\/ecmanaut.blogspot.com\/2006\/01\/jsonp-recipe-for-visitor-innovation.html\">Johan writes<\/a> of <span class=\"definition\" title=\"JavaScript Object Notation\">JSON<\/span> feeds, which sounds like the nifty idea of making your data available as a chunk of JavaScript that can be easily used by anyone.  Apparently <a href=\"http:\/\/del.icio.us\/help\/json\">del.icio.us already does this<\/a>.  The beauty of this is that, since web developers are already writing in JavaScript, they can just include your chunk of JavaScript in their own web applications and do something cool with it.  No parsing of <abbr title=\"eXtensible Markup Language\">XML<\/abbr> or other encoding formats required.  <!--more--><\/p>\n<p><script type=\"text\/javascript\" src=\"http:\/\/www.codedread.com\/googleads.js\"><\/script><br \/>\n<script type=\"text\/javascript\" src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\"><\/script><\/p>\n<p>I may be missing some key ideas here, but the following are a couple points that spring to mind:<\/p>\n<ul>\n<li>What about namespacing issues?  Also, the \"innovator\" seems very susceptible to name changes (or the service provider needs to be \"locked in\" to the naming choices they have made).<\/li>\n<li>How do you ensure that the JSON feeds don't sneakily embed some functional JavaScript (as opposed to purely data)?  You might be able to trust a data source one day, but forever?  <\/li>\n<li>How do you include JSON feeds dynamically into a web page?  Are you forced to use DHTML to construct a &#60;script&#62; tag that references the external JSON feed?<\/li>\n<li>\n<p>What About XML?  Most people like to (feel obliged to?) encode their data in XML so that they can leverage existing XML support that is ubiquitous nowadays.  Pointless arguments for or against XML aside, this means that if the service provider wants to provide their data in both formats, they have to do extra work.  Furthermore, there is no guaranteed payoff for providing it in JSON (Johan mentions user innovation, but this is definitely not a given benefit).  Thus, JSON feed support will lag.<\/p>\n<p>I think to spur adoption of JSON feeds, it would be great if someone wrote some generic code that would convert an arbitrary XML document\/node into the equivalent JSON fragment.  This could be done in PHP, XSLT or JavaScript.  Any and all would be useful.  Time to invoke the <a href=\"http:\/\/www.lazyweb.org\/\">Lazy Web<\/a>?<\/p>\n<p>For instance, given a web service already has a PHP file that provides a bunch of XML data (maybe extracted from a database), which is being used by their application, the web service provider can include the above mentioned XML-to-JSON PHP code and provide a switch in their PHP file that will provide the data as JSON instead.  Not a lot of extra work from the data provider's side since the code was already written for them, but they now provide the JSON feed for other users to possibly pick up and innovate.<\/p>\n<p>Or given that there already exists some data exposed as XML on another site and I want to use it in my own web application, I can copy the above-mentioned XML-to-JSON JavaScript code to my site, run the foreign XML through this function and then go forward.  This saves me the trouble of having to write a parser to handle the XML.<\/p>\n<\/li>\n<\/ul>\n<p>All in all, it seems like a cool idea that I need to investigate further.<\/p>\n<p><script type=\"text\/javascript\" src=\"http:\/\/www.codedread.com\/googleads.js\"><\/script><br \/>\n<script type=\"text\/javascript\" src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Johan writes of JSON feeds, which sounds like the nifty idea of making your data available as a chunk of JavaScript that can be easily used by anyone. Apparently del.icio.us already does this. The beauty of this is that, since web developers are already writing in JavaScript, they can just include your chunk of JavaScript [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,25,11,28],"tags":[],"class_list":["post-219","post","type-post","status-publish","format-standard","hentry","category-javascript","category-software","category-technology","category-web"],"_links":{"self":[{"href":"https:\/\/www.codedread.com\/blog\/wp-json\/wp\/v2\/posts\/219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codedread.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codedread.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codedread.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codedread.com\/blog\/wp-json\/wp\/v2\/comments?post=219"}],"version-history":[{"count":0,"href":"https:\/\/www.codedread.com\/blog\/wp-json\/wp\/v2\/posts\/219\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.codedread.com\/blog\/wp-json\/wp\/v2\/media?parent=219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codedread.com\/blog\/wp-json\/wp\/v2\/categories?post=219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codedread.com\/blog\/wp-json\/wp\/v2\/tags?post=219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}