Re: [xsl] XSLT functions for JSON

Subject: Re: [xsl] XSLT functions for JSON
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Sun, 18 May 2008 10:04:26 -0400
On Sun, 2008-05-18 at 15:52 +0200, Jesper Tverskov wrote:

> 
> 2. JSON has no way of handling even the most simple document oriented
> XML structure like: "h2, p, h2, p" if the order matters as is likely
> in the example. In JSON the order of the example will be changed to:
> "h2, h2, p, p".

You can use an array to set order. This is a place where I wish FXSL
would be more like the (reference?) implementation org.json's java
library where when an object  or array is encountered in the JSON, the
resulting XML is wrapped with 'o' and 'a' elements respectively.

> 
> 4. JSON has no standardized way of handling mixed content.
> Theoretically the most simple mixed content could be handled with a
> method similar to handling attributes but the prefix characters needed
> to tell text and element apart depends on who made the function. If
> mixed content consists of more than one text node and one element we
> run into the reordering problem.

Don't use JSON if you need to work with mixed content. It is not what is
made for.

Bottom line - there is no standardization. If you want to do xml2json
and json2xml you pick your library and write for it.

best,
-Rob

Current Thread