4 ms·
JSON is a data structure. XML is a text markup. Don't mix them up.
by chadlavi 7y ago
JSON is a data structure. XML is a text markup. Don't mix them up.
- thesuperbigfrog 7y agoXML is also a transform specification with XSLT (https://en.wikipedia.org/wiki/XSLT https://en.wikipedia.org/wiki/XSLT). XML is also a query language with XQuery (https://en.wikipedia.org/wiki/XQuery https://en.wikipedia.org/wiki/XQuery). XML is also a nested structure path specifier with XPath (https://en.wikipedia.org/wiki/XPath https://en.wikipedia.org/wiki/XPath). XML is also a file format with SVG (https://en.wikipedia.org/wiki/Scalable_Vector_Graphics https://en.wikipedia.org/wiki/Scalable_Vector_Graphics), OpenOffice XML (https://en.wikipedia.org/wiki/OpenOffice.org_XML https://en.wikipedia.org/wiki/OpenOffice.org_XML), OpenDocument (https://en.wikipedia.org/wiki/OpenDocument https://en.wikipedia.org/wiki/OpenDocument), ePUB (https://en.wikipedia.org/wiki/EPUB https://en.wikipedia.org/wiki/EPUB), DocBook (https://en.wikipedia.org/wiki/DocBook https://en.wikipedia.org/wiki/DocBook), and many others (https://en.wikipedia.org/wiki/List_of_XML_markup_languages https://en.wikipedia.org/wiki/List_of_XML_markup_languages). XML is also an data/object serialization format with libraries like Jackson (https://github.com/FasterXML/jackson https://github.com/FasterXML/jackson), YAXLib (https://github.com/sinairv/YAXLib https://github.com/sinairv/YAXLib), Boost (https://www.boost.org/doc/libs/1_38_0/libs/serialization/example/demo_xml.cpp https://www.boost.org/doc/libs/1_38_0/libs/serialization/exa...), Pyxser (https://github.com/dmw/pyxser https://github.com/dmw/pyxser), and many others. XML may not be as elegant as JSON, but it has a wide variety of uses and wide adoption across many programming languages (libraries), and disciplines.
- gwbas1c 7y agoI was going to make the same post, upvoted you instead! What's nice about JSON is that there's very little ambiguity in how to serialize / deserialize data structures. That's what's so powerful about it. As a result, using "magic" serializers with language-native data structures often works well and has little gotchas. In general, I think a lot of people hopped onto the XML bandwagon assuming that it would always sanely translate back and forth between XML and native data structures. This is not the case. When XML is the (cough) "best" format, the underlying data structures of different programs operating on the XML will look extremely different. Furthermore, XML terminology will end up leaking into business logic, because the semantics of the document are inseparable from handling it. In general, I think the biggest sign that XML is the wrong choice is when someone's using a "magic" serializer, or when the data structures very closely follow the document structure. In those cases, JSON was probably a better choice.