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

XML - JSON bi-directional conversion?

Expand Messages
  • Dragan
    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
    Message 1 of 4 , Apr 28, 2011
    • 0 Attachment
      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



      [Non-text portions of this message have been removed]
    • Tatu Saloranta
      ... There are multiple conventions for doing this, such as Badgerfish. Main question is why , that is, what is the reason for using such conversions: mostly
      Message 2 of 4 , Apr 29, 2011
      • 0 Attachment
        On Fri, Apr 29, 2011 at 5:32 AM, Dragan <dragansr@...> wrote:
        >
        > Is there some spec for XML - JSON bi-directional conversion?

        There are multiple conventions for doing this, such as Badgerfish.

        Main question is "why", that is, what is the reason for using such
        conversions: mostly because it is easy to just embed XML in JSON (and
        vice versa) as textual values. And while conversions are possible,
        they come in two main flavors: ugly and uni-directional. So often best
        way to convert is not to convert directly between XML and JSON, as
        their information models are not directly compatible (there is
        impedance)

        -+ Tatu +-
      • 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 3 of 4 , Apr 29, 2011
        • 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 4 of 4 , Apr 29, 2011
          • 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.