Hacker News new | ask | show | jobs
by revskill 525 days ago
JSON is same as XML.
5 comments

No it isn't, XML is an ecosystem with things like dedicated transfer protocols (EXI), schemas (XSD), transformers (XSLT) that JSON still doesn't have standardized/normalised even though JSON has been the norm for nearly 20 years. There's some projects of course (JSON Schema, OpenAPI), but they're separate and not part of the same standardization committee.
I don't remember anything about the XML ecosystem, but XML is already a totally different format from JSON without considering that.

  <body myattr="yeah">
    <thing>hi</thing>
    <thing thingattr="cool">hi2</thing>
    <otherkindathing>hi2</otherkindathing>
  </body>
can be thought of as nested objects, each having a typename, text content, and children. It doesn't translate nicely to JSON. Maybe:

  {"type": "body", "attrs": {"myattr": "yeah"},
   "children": [{"type": "thing", "content": "hi"}, ...]}
As someone who works with JSON every day and almost never deals with XML directly, it’s important to realize saying they are the same is like saying a pocket knife and a Swiss army knife are the same because they both have an extremely useful tool (and why would anyone ever use the thing with all that extra stuff I never use?). Not a perfect analogy but the one I think of for simplicity.
And XML is essentially lobotomized and extra verbose Lisp S-expressions, going back to the 1960’s
don't talk about my thesis, written in LaTeX, like that...

/j

Back in my day, real cowboys wrote their papers in PostScript, making their papers as inaccessible as possible for user of consumer-grade devices. /s

PS won on human readability and editability but lost on portability to Adobe's own internal competitor, PDF, and because it fought and lost to (La)TeX -> PDF & (La)TeX -> DVI -> PS.

PS: I once printed out and bound the PDF 1.3 spec[0] on 24 lbs. bleached dead trees on an HP LaserJet IIIP with over a million page count. Some of the nuclear engineers and scientists an office containing <50 people routinely printed thousand page documents every week.

0. https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandard...

JSON is great in it's own regards but the features are not comparable.
At least with XML, you can have custom datatypes, not just strings and numbers and booleans.

In all seriousness, everything in JSON can be expressed as XML; but not necessarily the other way around.

So incredibly true. And that one time you see what XML can do that little else can.

Like that time there were hundreds of forms to build, refused, held a silent protest until a reasonable way presented itself.

Enter "XML Form Template" or "XML Form Definition.", A form is generated from the XML in html, filled in, and on submit, the XML is filled back in.

Built one form renderer and done. Never got old watching it.

XForms (W3C standard)

https://www.w3.org/TR/2003/REC-xforms-20031014/slice2.html

Other way around works too (I gave an example above), it's just not pretty in either direction.

XML makes sense for open-ended, human-written things like documents or apps. It doesn't work so well for APIs and other machine-read/written things where you'd normally use JSON.

Text is the same as JSON.