why is embedding JSON in XML bad?
It's sorta like the database normalization debate. It's cleaner and more elegant to do everything in pure XML (or normalize your database schema), that way you're not unnecessarily coupled to your particular implementation. But if you have to then convert the XML to JavaScript objects (or join 5 tables for every damned SELECT
), you may end up writing lots of extra code and incur unnecessary performance hits.
It all depends on how you balance convenience with formal correctness. If this is an XML interchange format that will be standardized by the W3C and used by millions then dear God, do not use JSON. If this is for an in-house app that'll only be processed by code you yourself have written then screw it, just throw the JSON in there and move on!
In my opinion XML is the prefered Data transfer representation, but JSON is far more expressive when it comes to Maps and Arrays. I would have no issue with embedding JSON into xml to represent a list or map.
As an interchange format using two formats puts extra burden on people who want to inter-operate with you. Now they need to have an XML parser and a JSON parser.
It also makes it harder for people to grok the format, as they have to mentally switch gears when thinking about different parts of your file.
Finally, you won't be able to easily do things that look at the entire structure at once. For example, you can't use XPath to grab JSON bits, nor can you treat the entire response as a JavaScript object. By mixing two formats you get a "worst of both worlds" problem when it comes to manipulating the data.