
Is there any accepted standards for having Document Type Definition in JSON? - mofosyne
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.
======
mofosyne
For extra context, this is a valid XML doc with embedded DTD:

    
    
       <?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>
    

This is a valid XML doc with an externally linked DTD:

    
    
       <?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>

------
dylz
Curiosity: why do you want this in JSON?

If you already have explicit schemas in mind, why not use some packed schema-
based representation that ends up being more compact?

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.

------
hootbootscoot
wow, so you can embed your xml in your json.

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

