1640Re: XML - JSON bi-directional conversion?
- Apr 29 9:24 AMThis "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 email@example.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
- << Previous post in topic Next post in topic >>