[Dimitre Novatchev:XSL-List] Understanding JSON: Why JSON and XML are Incompatible and Why You Should Care
Dimitre Novatchev recently posted the following to XSL-List, something of which I thought would be of both interest and benefit to those of you in Land-O-XML who care about things kinds of things. As such,
> I have the nice FXSL function, f:json-document(), working but I am
> wondering if it can transform any JSON generated from XML back to XML?
The short answer is that there isn’t a 1:1 mapping between XML and JSON.
This means that there isn’t a function
f : XML Document —> JSON Object
((f)-1) . f = f . ((f)-1) = id
Here I use ((f)-1) to denote the reverse function of f(), as I cannot
use superscripts in this plain text format.
FXSL uses the JSON grammar as published at http://www.json.org.
The JSON grammar in RFC 4627 is much more loose and describes a JSON
object that does not correspond to an XML document and even not to
what the value of an XSLT 2.0 variable may be (secuence of items of
any type), because for example it allows a named object to have an
array of unnamed scalar (let’s say integer) children.
People need to be aware of the whole JSON hype and not be easily lured
into substituting it for the stable and proven useful by years of
practical experience XML document representation.
Any claims of better readability of JSON become obviously wrong for
any but the smallest size JSON objects.