JSON

Developing the next generation of open data interchange

« PreviousNext »

XMLHttpRequest.responseJSON

14 January 2008

With the recent W3C proposal for cross site XMLHttpRequest capabilities through Access Control headers, JSONRequest may not be the only standards based client side approach for creating mashups that utililize cross site data. One of the advantages of JSONRequest is that it can safely and efficiently evaluate JSON data (safer and more efficiently than an “eval” call). However, the new cross-site enabled XMLHttpRequest could provide this capability as well with the intuitive addition of a responseJSON property. Currenty the XMLHttpRequest object has responseXML property that returns the resource parsed as XML (when the content type is text/xml or application/xml). However, since JSON is becoming the data format of choice for XMLHttpRequest, it would seem logical to provide a property that returns the resource as parsed JSON (when the content type is application/json).

With the potential new cross-site capabilities of XHR, I have been thinking about how I could port CrossSafe to the XHR API. Since CrossSafe operates by passing JavaScript objects (parse JSON data) across iframes, it would create a large inefficiency to reserialize the JavaScript objects back to JSON in order to fulfill the standard responseText property of XHR (since it would probably just be re-parsed back to JavaScript objects again). It would be much more efficient to expose the parsed JSON data through a responseJSON property. I would love to see this property added to the XMLHttpRequest API so the CrossSafe/Subspace technique could be accessed efficiently through the widely known and understood XHR API.

Posted in Uncategorized | Trackback | del.icio.us | Top Of Page

No comments yet

Leave a Reply