JSON Schema vs XML Schema JSON Schema vs XML Schema json json

JSON Schema vs XML Schema


I'm pretty sure the answer is yes in a while.

Using current JSON Schema draft 04 (hyperschema) you can currently map the most of XML Schema to JSON Schema. There are some ugly workarounds which will be obsolete with draft 05: I am pretty sure that the proposals propertyLinks will "make it" into the next draft, see this page:https://github.com/json-schema/json-schema/wiki/v5-Proposals

There are also existing projects, e.g. owl2vowl and webowl is using a to JSON Schema converter. It is Java.I am not sure how far the XML Schema support is.However:

I began writing a JSON Schema "playground" in javascript (with an optional 'node.js part'). In javascript there is a solution for schema.org. And I asked myself how to import OWL / RDFS / XML Schema in a similar manner. I am 70% ready with the OWL / RDFS part now.

So if your interested in this, we could setup a discussion for the XML Schema part and I could push to github before.


I'm pretty sure the answer is no.

Firstly, it's quite hard to define a completely lossless mapping between JSON and XML at the instance level even before you start thinking about schemas. So the concept of "the same data structures" needs qualification.

Much of XML Schema is concerned with grammars and content models, for example saying that a section consists of an optional heading followed by zero or more paragraphs, each of which can be a p, ul, or table element. I don't think there's anything remotely like that in JSON Schema. Arrays in JSON Schema seem to be treated as uniform and homogenous.