TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Is there any accepted standards for having Document Type Definition in JSON?

1 pointsby mofosyneover 5 years ago
Is it just me or does JSON still lack a community accepted way of having a self validating document.<p>I&#x27;ve been paying attention to development of CBOR and I am quite interested in the CDDL standard that is being developed for validating CBOR data.<p>https:&#x2F;&#x2F;tools.ietf.org&#x2F;html&#x2F;draft-ietf-cbor-cddl-00#section-4.2<p>However it is not quite like XML, especially how XML DTD tag links to a document type definition file.<p>What would be the trajectory of JSON in regards to self validation and is it even needed?<p>----------<p>Side Note: I quite like the semantic tagging of CBOR and it would be great if JSON or anything that succeeds JSON would take semantic tagging into mind.

3 comments

mofosyneover 5 years ago
For extra context, this is a valid XML doc with embedded DTD:<p><pre><code> &lt;?xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot; standalone = &quot;yes&quot; ?&gt; &lt;!DOCTYPE address [ &lt;!ELEMENT address (name,company,phone)&gt; &lt;!ELEMENT name (#PCDATA)&gt; &lt;!ELEMENT company (#PCDATA)&gt; &lt;!ELEMENT phone (#PCDATA)&gt; ]&gt; &lt;address&gt; &lt;name&gt;Tanmay Patil&lt;&#x2F;name&gt; &lt;company&gt;TutorialsPoint&lt;&#x2F;company&gt; &lt;phone&gt;(011) 123-4567&lt;&#x2F;phone&gt; &lt;&#x2F;address&gt; </code></pre> This is a valid XML doc with an externally linked DTD:<p><pre><code> &lt;?xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot; standalone = &quot;no&quot; ?&gt; &lt;!DOCTYPE address SYSTEM &quot;address.dtd&quot;&gt; &lt;address&gt; &lt;name&gt;Tanmay Patil&lt;&#x2F;name&gt; &lt;company&gt;TutorialsPoint&lt;&#x2F;company&gt; &lt;phone&gt;(011) 123-4567&lt;&#x2F;phone&gt; &lt;&#x2F;address&gt;</code></pre>
dylzover 5 years ago
Curiosity: why do you want this in JSON?<p>If you already have explicit schemas in mind, why not use some packed schema-based representation that ends up being more compact?<p>Alternatively, what is stopping you from just adding a JSON Schema key to your JSON document? If you don&#x27;t want to do this, what is stopping you from hard-defining a JSON schema when ingesting the string? It isn&#x27;t like you want anyone in the world to randomly be able to give you a schema to validate against.
hootbootscootover 5 years ago
wow, so you can embed your xml in your json.<p>make sure you can arbitrarily attach your DTD at any point in your json&#x27;s heirarchy so then you can have fun baffling yourself in nested parsing... introducing jsonxml! yay