4 ms·
JSON 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 act
by silicaroach 7y ago
JSON 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.