4 ms·
Is there any accepted standards for having Document Type Definition in JSON?
Is it just me or does JSON still lack a community accepted way of having a self validating document.
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.
https://tools.ietf.org/html/draft-ietf-cbor-cddl-00#section-4.2
However it is not quite like XML, especially how XML DTD tag links to a document type definition file.
What would be the trajectory of JSON in regards to self validation and is it even needed?
----------
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 7y agoFor 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 7y agoCuriosity: 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 7y agowow, 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