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

Re: XML - JSON bi-directional conversion?

Expand Messages
  • stephen.mckamey
    This impedance mismatch has been a source of a lot of solutions with various trade-offs. One of the first encodings is called BadgerFish which uses an @
    Message 1 of 4 , Apr 29 9:24 AM
    • 0 Attachment
      This "impedance mismatch" has been a source of a lot of solutions with various trade-offs. One of the first encodings is called BadgerFish which uses an '@' prefix to distinguish attributes from child elements. Many people have created variations of this to attempt to solve the various issues that arrise.

      I created JsonML (http://jsonml.org) back in 2006 to specifically deal with lossless bi-directional translation when the XML isn't data-centric but is markup-centric. When there is "mixed-mode content" most other representations can't represent it. Mixed-mode is when elements sit as siblings to textual nodes. This is uncommon in serialized XML data, but is the norm with XML markup like XHTML.

      JsonML is a less intuitive mapping than the BadgerFish-style, but it's intent was to be an intermediate format interpreted by machine not humans. In an email exchange with Crockford, we settled upon using an array as the element (rather than an object with a children array) and it reduced the size of the mapping significantly.

      The most complete list of XML-to-JSON mappings to date is on this wiki:

      http://wiki.open311.org/index.php?title=JSON_and_XML_Conversion

      It shows how a document could be translated between each of the formats and gives some good detail about each.

      --- In json@yahoogroups.com, "Dragan" <dragansr@...> wrote:
      >
      >
      > Is there some spec for XML - JSON bi-directional conversion?
      >
      > I have observed a few tools that have this feature,
      > including JSON-java by Douglas Crockford
      > <https://github.com/douglascrockford/JSON-java/blob/master> ,
      > but no description of how to resolve "impedance mismatch"
      > between data-oriented JSON and document-oriented XML...
      >
      > Here is a link to my blog comment about issues of this conversion
      > http://dragansr.blogspot.com/2011_04_10_archive.html#1877312882670385155
      > <http://dragansr.blogspot.com/2011_04_10_archive.html#187731288267038515\
      > 5>
      >
      > Thanks
      >
      > Dragan
    • John Cowan
      ... I d like to push for JsonML being the official JSON-syntax representation of the MicroXML data model, since they match perfectly: an element has a name,
      Message 2 of 4 , Apr 29 10:36 AM
      • 0 Attachment
        stephen.mckamey scripsit:

        > I created JsonML (http://jsonml.org) back in 2006 to specifically
        > deal with lossless bi-directional translation when the XML isn't
        > data-centric but is markup-centric. When there is "mixed-mode content"
        > most other representations can't represent it. Mixed-mode is when
        > elements sit as siblings to textual nodes. This is uncommon in
        > serialized XML data, but is the norm with XML markup like XHTML.

        I'd like to push for JsonML being the official JSON-syntax
        representation of the MicroXML data model, since they match perfectly:
        an element has a name, attribute map, and sequence of elements.

        > http://wiki.open311.org/index.php?title=JSON_and_XML_Conversion

        Good to know about.

        --
        John Cowan http://ccil.org/~cowan cowan@...
        SAXParserFactory [is] a hideous, evil monstrosity of a class that should
        be hung, shot, beheaded, drawn and quartered, burned at the stake,
        buried in unconsecrated ground, dug up, cremated, and the ashes tossed
        in the Tiber while the complete cast of Wicked sings "Ding dong, the
        witch is dead." --Elliotte Rusty Harold on xml-dev
      Your message has been successfully submitted and would be delivered to recipients shortly.