Loading ...
Sorry, an error occurred while loading the content.

905Re: JSoda

Expand Messages
  • Kyle Alan Hale
    Nov 14, 2007
    • 0 Attachment
      > I may be bit slow, but I am not sure I understand why you would want
      > to wrap DOM within JSON?
      > Why not deal with xml via DOM as is? And when transferring, let
      > efficient xml generators/parsers take care of marshalling aspects?
      >
      > I do understand the interoperability aspects sometimes require one to
      > use mappings to make things work (albeit inefficiently or awkwardly),
      > but are there some other benefits?
      >
      > -+ Tatu +-
      >

      The DOM element objects themselves aren't being wrapped in JSON. In
      fact, JSoda isn't JSON at all, it's just nested JavaScript objects.
      Each object type represents a different thing:

      Object object -> DOM element
      Array object -> DOM document fragment
      String object -> DOM text node

      However, it is JSON compliant, meaning that you can conveniently store
      or transmit representations of DOM via, say, JSON RPC, or the proposed
      JSONRequest, or any other method of transmitting textual information.
      So, if you're using JSON anyway to transmit data, a JSoda object
      could be embedded within the JSON text and not cause any problems with
      JSON parsers... and not need an additional XML parser. In my case,
      I'll be using it to transmit XHTML-based rich-text.. and I didn't want
      to use a full fledged xml solution. I may change my mind about that
      as the project that I'm working on develops, but for now this is perfect.

      I also use JSoda objects to build DOM elements, using the script
      available on the site. Sure, I could do everything in XHTML and
      innerHTML it into my doc, but I'd rather be as ready for the future as
      possible by implementing a wrapper around standards-based DOM methods.
      Or, I could use XML and parse it, but the parsing overhead of a
      native JavaScript object based solution is almost nonexistent,
      compared to the intrinsically bulky XML parsers out there.

      ha.. I didn't expect anyone to ask "Why not just use XML?" in the JSON
      group. If I were intending for this to be a markup language in
      itself, then, you're right, XML would be more appropriate. But JSoda
      is just representing one language (XHTML) in terms of another
      (JavaScript). I like being able to think of DOM nodes as JavaScript
      objects when working on JavaScript/AJAX based applications, but I
      don't like the tedium of using the DOM functions on their own. JSoda
      meets both needs with a syntax that is analogous to DOM objects, but a
      hell of a lot easier to build.
    • Show all 7 messages in this topic