One of the purported advantages of JSON Schema is that it
is simpler than XML Schema. After converting an XML Schema to JSON Schema, I am skeptical
of such claims. In a previous post, I invited suggestions for converting
an xs:complexType with mixed content to an equivalent JSON Schema. After assessing several approaches, I arrived at a JSON Schema representation. I represented the following xs:complexType <xs:complexType
name="InternationalString"
mixed="true"> with this JSON Schema: "InternationalString":
{ One could reasonably argue that the XML Schema representation
is simpler. At the very least, it is shorter. The XML Schema that I converted has a second xs:complexType
which extends the above xs:complexType with an attribute: <xs:complexType
name="PedigreeStringType"> I believe this xs:complexType cannot be represented in JSON
Schema. (If that is not correct, please let me know). The best that one can do is to copy the JSON Schema definition of
"InternationalString"
and add the version
attribute: "PedigreeStringType":
{ As you know, the danger of copy-and-paste is that if the
parent type (InternationalString)
is changed, then I must ensure that the changes are also made wherever I did a copy-and-paste. Summary: I think it is probably true that JSON Schema is
simpler than XML Schema for simple things. But for complex things, such as expressing mixed content and creating type hierarchies, I think XML Schema is simpler and more powerful.
I welcome your comments. /Roger |