4 ms·
XLM had DTDs and Schemas 20 years ago. JSON is still figuring it out.
by theshrike79 6mo ago
XLM had DTDs and Schemas 20 years ago.
JSON is still figuring it out.
- abustamam 6mo agoJson has json schema. What are DTDs?
- theshrike79 6mo agoJSON Schema has existed for maybe 6 years in theory, in practice a few years. As for DTD: https://en.wikipedia.org/wiki/Document_type_definition https://en.wikipedia.org/wiki/Document_type_definition Basically it tells the system what elements are allowed in which places and what attributes they can contain. <!ELEMENT html (head, body)> Defines a html element that can contain a head and body, nothing else. Anything extra or missing will fail the validator. It was kinda-sorta eventually superseded by XML Schema that could also define what KIND of data the attributes could contain, but did exist at the top of XML/HTML/SGML documents for years.
- abustamam 6mo agoAh interesting. Whenever I write an API I'll use Zod and whatever middlewares my framework needs to generate json schema for consumers, and whenever I consume an API I will use Zod to parse. It would be nice if it were just built into the spec though!
- thiht 6mo agoIf XML+DTD was so great, it would still be used.
- abustamam 6mo agoI don't think that's a fair assessment. Plenty of great technologies died out for many reasons unrelated to its effectiveness.