2008-05-16 @ 13:29#

saw this today and was reminded of the time i spent pondering how to handle JSON<->XML issues in my exyus web engine. this quote sums is up nicely:

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

such that

((f)-1) . f = f . ((f)-1) = id

that's why i opted to go with a simple one-way JSON-to-XML pattern. it doesn't every *try* to go the other way. instead, web authors use hand-crafted XSLT to create JSON output from internal XML (of any kind). this makes for a bit more work, but cuts out a *huge* load of trundling and sweating over getting a consistent round-tripping of XML and JSON. not gonna happen.