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

1510Re: Where our JSON product is heading: XML to JSON and Back

Expand Messages
  • stephen.mckamey
    Apr 6 11:43 AM
      The attributes object is optional (see the BNF at http://jsonml.org) so you can drop it if empty to make more compact.

      The example XML:

      <description abc="http://example.com">
      <abc:title>hi there</abc:title>
      </description>

      would encode in JsonML as:

      ["description", {"abc":"http://example.com"},
      ["abc:title", "hi there"]
      ]

      To encode mixed content, I think you mean like this:

      <div class="section">
      <p class="description">This is how <b>inline elements</b> get marked up.</p>
      </div>

      would encode to the JsonML:

      ["div", {"class":"section"},
      ["p", {"class":"description"}, "This is how ", ["b", "inline elements"], " get marked up."]
      ]

      Optionally, you could even encode the document whitespace as well if this was significant to the original XML.

      ["div", {"class":"section"},
      "\r\n\t",
      ["p", {"class":"description"}, "This is how ", ["b", "inline elements"], " get marked up."],
      "\r\n"
      ]

      --- In json@yahoogroups.com, "Mark Joseph" <mark@...> wrote:
      >
      > Cool stuff, can you show me an example of how JsonML handles XML mixed content, that is not clear to me from the web site.
      >
      >
      > And just so it is clear to me, the namespace example would be something like:
      >
      > <description abc="http://example.com"><abc:title>hi there</abc:title></description>
      >
      > becomes
      >
      > [ "description", {"abc" : "http://example.com"},
      > [ "abc:title", {}, "hi there" ]
      > ]
      >
      > So the JSON application has to find the meaning of "abc:title", if it cares, like XML applications do by looking for the first enclosing element with
      > a definition for "abc"?
      >
      >
      >
      > Thanks,
      >
      > Mark Joseph, Ph.D.
      > President
      > P6R, Inc
      > 408-205-0361
      > mark@...
      > Skype: markjoseph_sc
      > _____
      >
      > From: stephen.mckamey [mailto:stephen@...]
      > To: json@yahoogroups.com
      > Sent: Tue, 06 Apr 2010 10:11:22 -0700
      > Subject: [json] Re: Where our JSON product is heading: XML to JSON and Back
      >
      >
      >
      >
      >
      >
      >
      >
      > JsonML ( http://jsonml.org ) handles all of these issues and has been embraced by quite a number of places. Many JSON encoders already include support.
      >
      > It handles namespaces the same way that XML 1.0 did: include the name as "prefix:local-name" and the URI to prefix mapping (xmlns:abc="http://example.com/abc") as the attribute of the node that declared it.
      >
      > An early implementation of JsonML took a similar approach to including a child object, but ultimately after some design discussions with Douglas Crockford, his suggestion was to make the actual element an array like the child object and have the element name be the first item.
      >
      > This positional structure has been the biggest part that people have disliked about JsonML, but yet in many XML documents (XHTML for example, being the primary use case) position of the child nodes is critical to the meaning of the document. So you get much smaller documents when you just add the element name as the first child and make elements arrays.
      >
      > I'd encourage you to embrace JsonML and contribute to a standard that has been around for four years already rather than creating a slightly different approach.
      >
      > --- In json@yahoogroups.com, "Mark Joseph" <mark@> wrote:
      > >
      > > For people interested in this topic. We are always open to comments and questions.
      > >
      > > https://www.p6r.com/articles/2010/04/05/xml-to-json-and-back/
      > >
      > >
      > > Best,
      > >
      > > Mark Joseph, Ph.D.
      > > President
      > > P6R, Inc
      > > 408-205-0361
      > > mark@
      > > Skype: markjoseph_sc
      > >
      > >
      > >
      > > [Non-text portions of this message have been removed]
      > >
      >
      >
      >
      >
      > [Non-text portions of this message have been removed]
      >
    • Show all 28 messages in this topic