Re:The Emacs Problem (2005)
by ingenter on Thursday February 27, 2014 @11:13AM
(#7312940)
One can make a 1:1 mapping from XML to JSON, but it is going to be verbose.
or (hello, LISP)
[ Parent
| on HN ]
Yes, that's what I mean. Both XML and JSON can ultimately encode everything, but they both do indeed have strengths over the other. The problem with XML isn't that it is a "bad thing" that should never be used, the problem is that it become trendy and people started using it for all sorts of things it shouldn't have been, combined with a healthy dose of it being used by a lot of people who didn't even understand XML. (XML isn't that complicated, but there's more to it that "tags, attributes, and text".) When you're in a domain where XML really should be used, you're going to regret trying to jam JSON into that domain.
Also, side observation, that Lisp-like encoding is pretty icky as-is (deciding if something is a tag or text by how deep the array is?), and gets worse if the XML uses attributes.
I think the various XML Schema-ifications don't help either. XML is fairly poorly defined while JSON is pretty precise. This has more to do with a heavy industry of poorly defined, implied semantics atop XML than anything about the raw format, though.
Correct me if I'm wrong but I think you could get away with:
I don't think your second example is much at all like Lisp and I think to actually achieve something lispy, JSON would need some kind of symbol type, so you can do:
['Foo, ['Some Text', ['Bar, 'more text']]]
Though, mix in attributes, and it's just a nightmare.After all, it's not like:
'(Foo "Some text" (Bar "more text"))
Or with an admittedly not-very-well-thought-out attribute: '(Foo "Some text" (Bar ([] (name "Baz")) "more text"))
For: <Foo>Some text <Bar name="Baz">more text</Bar></Foo>
Though there may be a better way of representing attributes....