Re: XML - JSON bi-directional conversion?
- 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:
It shows how a document could be translated between each of the formats and gives some good detail about each.
--- In firstname.lastname@example.org, "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
- stephen.mckamey scripsit:
> I created JsonML (http://jsonml.org) back in 2006 to specificallyI'd like to push for JsonML being the official JSON-syntax
> 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.
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_ConversionGood 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