nextwebgen.com

The Next Generation Web Now

JSON 2.0: Libraries and browser support

Filed under: Web 2.0 News — Dion Almaer at 4:00 am on Thursday, January 31, 2008

John is at it again, writing a piece on recent news surrounding JSON.

He links to an updated library by Douglas Crockford, PLAIN TEXT

JAVASCRIPT:

  1.  
  2. JSON.stringify({name: “John”, location: “Boston”});
  3. // => "{’name’:'John’,'location’:'Boston’}"
  4. JSON.parse(“{’name’:'John’,'location’:'Boston’}”);
  5. // => {name: "John", location: "Boston"}
  6.  

It also turns out that Mozilla implemented this functionality in the browser (time for a wrapper):

JAVASCRIPT:

  1.  
  2. var nativeJSON = Components.classes[“@mozilla.org/dom/json;1″]
  3.     .createInstance(Components.interfaces.nsIJSON);
  4. nativeJSON.encode({name: “John”, location: “Boston”});
  5. // => "{’name’:'John’,'location’:'Boston’}"
  6. nativeJSON.decode(“{’name’:'John’,'location’:'Boston’}”);
  7. // => {name: "John", location: "Boston"}
  8.  

And in conclusion:

The final, and most important, step is being worked on right now - a way to access native JSON encoding and decoding from web pages. How it’ll be accessible is up to some debate (as having its naming conflict with an existing object would be a really bad thing). Regardless, there should be something within the browser by the time the Firefox 3 betas wrap-up.

Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blogmarks
  • del.icio.us
  • De.lirio.us
  • digg
  • NewsVine
  • YahooMyWeb

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>