Is it just me or does JSON still lack a community accepted way of having a self validating document.<p>I'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://tools.ietf.org/html/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.
For extra context, this is a valid XML doc with embedded DTD:<p><pre><code> <?xml version = "1.0" encoding = "UTF-8" standalone = "yes" ?>
<!DOCTYPE address
[
<!ELEMENT address (name,company,phone)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT company (#PCDATA)>
<!ELEMENT phone (#PCDATA)>
]>
<address>
<name>Tanmay Patil</name>
<company>TutorialsPoint</company>
<phone>(011) 123-4567</phone>
</address>
</code></pre>
This is a valid XML doc with an externally linked DTD:<p><pre><code> <?xml version = "1.0" encoding = "UTF-8" standalone = "no" ?>
<!DOCTYPE address SYSTEM "address.dtd">
<address>
<name>Tanmay Patil</name>
<company>TutorialsPoint</company>
<phone>(011) 123-4567</phone>
</address></code></pre>
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't want to do this, what is stopping you from hard-defining a JSON schema when ingesting the string? It isn't like you want anyone in the world to randomly be able to give you a schema to validate against.
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's heirarchy so then you can have fun baffling yourself in nested parsing... introducing jsonxml! yay