7 ms·
I beg to differ. In its raw form XML is not much different from JSON. It is more verbose (e.g. start and end delimiters versus a name tag in JSON) but overall
by datalist 7y ago
I beg to differ.
In its raw form XML is not much different from JSON. It is more verbose (e.g. start and end delimiters versus a name tag in JSON) but overall very similar, if not identical in terms of features. Schemas are a different topic.
Reading and writing with automated tools very much depends on these tools and not so much on the syntax itself.
JSON is slightly slimmer and less verbose but does not really offer any fundamental advantages. Both syntaxes are very similar. The reason why JSON is more popular nowadays can be most likely found its relatively close ties to JavaScript and JavaScript's success in web development.
- silicaroach 7y agoJSON is not 'slightly' slimmer and less verbose, it is considerably so and it's format very_obviously_ conforms to an object structure and so a JSON file is actually legible. xml was just a port of html with all the verbosity. JSON is a cleaner expression of what xml was trying to represent, Occam's razor and _that's_ why JSON is more popular
- datalist 7y agoI believe you are wrong, but let us simply agree to disagree ;)
- datalist 7y agoI believe I was a bit too quick in just dismissing your response, my apologies, so let me please elaborate on why I believe you are wrong - "Obviously conforms"? XML does too. Both are hierarchical document formats. Their syntax is different, thats about it. - "Considerably slimmer"? That is arguable, I'd say "slightly". But yes, JSON is somewhat leaner. So what, that doesnt make it intrinsically superior. - "Legibility"? That mostly depends on the formatting. Especially in today's world and its minifiers essentially nothing is legible any more. JSON, being less verbose, might have a fraction of an advantage here, but again thats about it. Examples? Sure. Would you argue the following JSON document is legible? [{"_id":"5e120086aa2b07d5af7ddda3","index":0,"guid":"ae823405-6305-4c29-a8d3-429423e0ff7c","isActive":false,"balance":"$2,616.37","picture":"http://placehold.it/32x32","age":36,"eyeColor":"green","name":"Lyons Pollard","gender":"male","company":"TECHMANIA","email":"lyonspollard@techmania.com","phone":"+1 (870) 441-2429","address":"722 Truxton Street, Osmond, Indiana, 1802","registered":"2018-03-14T10:56:23 -01:00","latitude":43.427473,"longitude":-78.16956,"tags":["id","voluptate","velit","sit","duis","velit","proident"],"friends":[{"id":0,"name":"Elba Fernandez"},{"id":1,"name":"Rosalinda Morrow"},{"id":2,"name":"Hannah Leblanc"}],"favoriteFruit":"apple"}] Didnt think so. In comparison its XML equivalent is pretty legible <?xml version="1.0" encoding="UTF-8"?> <root> <element> <_id>5e120086aa2b07d5af7ddda3</_id> <address>722 Truxton Street, Osmond, Indiana, 1802</address> <age>36</age> <balance>$2,616.37</balance> <company>TECHMANIA</company> <email>lyonspollard@techmania.com</email> <eyeColor>green</eyeColor> <favoriteFruit>apple</favoriteFruit> <friends> <friend> <id>0</id> <name>Elba Fernandez</name> </friend> <friend> <id>1</id> <name>Rosalinda Morrow</name> </friend> <friend> <id>2</id> <name>Hannah Leblanc</name> </friend> </friends> <gender>male</gender> <guid>ae823405-6305-4c29-a8d3-429423e0ff7c</guid> <index>0</index> <isActive>false</isActive> <latitude>43.42747</latitude> <longitude>-78.16956</longitude> <name>Lyons Pollard</name> <phone>+1 (870) 441-2429</phone> <picture>http://placehold.it/32x32</picture> <registered>2018-03-14T10:56:23 -01:00</registered> <tags> <tag>id</tag> <tag>voluptate</tag> <tag>velit</tag> <tag>sit</tag> <tag>duis</tag> <tag>velit</tag> <tag>proident</tag> </tags> </element> </root> Yes, more verbose - which I already addressed - but nonetheless self-explanatory. One advantage of JSON? Additionally to strings its core syntax defines three additional value types, whereas in XML everything is a string. XML and JSON are so similar they could be considered siblings. JSON's popularity does not stem from being "a cleaner expression of what xml was trying to represent" because everybody using it made a careful evaluation and decided after long deliberation that JSON is "Occam's razor", but simply because it is the default choice in JavaScript and comes with native support, whereas XML support is pretty shaky in Vanilla JavaScript. That is why - to adopt the same confident attitude ;) Would I slightly favour JSON over XML these days? Yes, probably slightly, but certainly not because it was better or offered things XML didnt.
- rs23296008n1 7y agoI can easily have a JSON parser up and running in basically any language in my toolkit usually in minutes. This is not the case with XML. JSON exists between the bureaucratic XML at the top and the anarchy of csv/tsv at the bottom. I'd rather operate on JSON data: fast to process, easily pulled apart, etc. CSVs are a free-for-all that are either well formed or a subtle spaghetti of loose commas and bad quoting. What XML has that the others don't is verbosity and that helps in rebuilding damaged data. I can rebuild an XML record easier than JSON and XML lets me see where records are incomplete/malformed. These are its strengths. But every new project I work on has JSON because the parsers run fast and everything is legible. I can edit a JSON file without it becoming a sea of text like XML. To each their own, XML has a place and so does JSON. I know as fact that for my purposes XML uses much more time and memory and both of those cost money.
- datalist 7y agoI am afraid you are still mixing two unrelated things. The document format and potential libraries. Yes, XML libraries tend to be unnecessarily complex (particularly with Java) and are often a drag, but this is not about about the format. Even the bureaucracy you mentioned is not inherent to XML itself. You can perfectly use XML without schema insanity, just like JSON. XML is quite more verbose (which might help in a rebuild you mentioned) but is generally quite alike to JSON. Even the performance and memory issues you mentioned are not specific to XML but rather to libraries which went bananas. My point is JSON is not more popular these days because it is inherently superior. JSON is more popular because it was the default choice in a JavaScript environment and - probably - because those who implemented JSON libraries were a tad more sane than their XML counterparts.
- rs23296008n1 7y agoIf the spec produces bad implementations often enough then the spec itself becomes suspect. It implies too many misunderstandings are occurring. I find XML tooling far more bulky than that for JSON. For data interchange between C++, python and lua plenty of support for JSON makes this clean and painless. The files are relatively clean and easy to maintain and fast to read/write. I'd not even suggest XML now since initial prototyping showed it too inconvenient for what we do.