XSD to JSON Schema

32,465 views
Skip to first unread message

RAMESH BABU

unread,
Mar 12, 2014, 11:45:44 AM3/12/14
to json-...@googlegroups.com
Hi,
 
We have a scenario where XSD to be converted to JSON schema.. My questions to the group
 
1. Is there a tool to convert XSD to JSON schema ?.
2. Is there a validator for JSON Schema ?..
3. Namespaces in JSON is the best to have or not required ?..
 
Thanks
Ramesh

Geraint

unread,
Mar 31, 2014, 7:52:43 AM3/31/14
to json-...@googlegroups.com
Hi - sorry this was missed for a while.

First, you need to define exactly how XML is transformed into JSON, as the data paradigms are quite different.  Once you've defined that, then perhaps an XSD -> JSON Schema convertor might be possible (not certain, and possibly not elegant) - but it will very much depend on exactly how you're doing that first translation.

There are many validators for JSON Schema, in a variety of languages - see the first section of this page: http://json-schema.org/implementations.html

Geraint

Sebastian Lasse

unread,
Feb 5, 2015, 6:15:41 AM2/5/15
to json-...@googlegroups.com
There is a tool which is a result of a Bachelor Thesis in germany. SWI prolog and the swipl binary are required:

Sebastian Lasse

unread,
Feb 5, 2015, 6:18:56 AM2/5/15
to json-...@googlegroups.com
sorry, pasted only 50% ;) :
I am working on http://github.com/redaktor/owl2jsonschema.js and begin working on the xsd constraints [looking for help].

Sebastian Lasse

unread,
Mar 4, 2015, 5:14:45 AM3/4/15
to json-...@googlegroups.com
In the meantime I checked the mentioned Bachelor Thesis and tool.
 
Unfortunately I could not find any XSDs in the wild where it worked.
I tested against prismstandard and IPTC rNews. 
It seems to be about what is written here:
"From XML Schema to JSON Schema - Comparison and Translation with Constraint Handling Rules"
- in the synopsis
::

Because the also introduced attribute groups and model groups are only placeholders in complex type definitions, we will omit those components for our translator. 

Unfortunately that seems to mean: "If there are named groups (instead of elements) it will fail" ...

Aleksei Valikov

unread,
Jul 1, 2015, 6:14:41 AM7/1/15
to json-...@googlegroups.com
Hi Ramesh,

a bit late answer - and an advertisement at the same time.

I've written a tool which generates JSON Schema for XML Schemas:


It is based on JAXB/XJC so it's able to process a huge variety of schemas.

Please see the related quetsion on Stack Overflow:


Best wishes,
Alexey

kaza...@kazanture.com

unread,
Oct 7, 2015, 6:59:50 AM10/7/15
to JSON Schema
Hi Aleksei,
your schema generator works very well. But it seems to be not generating for xsd:restriction and xsd:pattern.
is there something i am missing?
Can you help me?

Thanks,
Emre

rajashekh...@gmail.com

unread,
Jun 10, 2016, 10:53:41 AM6/10/16
to JSON Schema
Hi,
xsd2json is working and producing the json. What about validating the same?? i mean, what if i would like to convert XSD to JSON schema and XML to JSON and validate the results of both conversions???

+Raja

codebug

unread,
Feb 8, 2017, 10:13:30 AM2/8/17
to JSON Schema, rajashekh...@gmail.com
Hey Raja,

Any further update on this ? how did you manage to validate ? 

Also any idea about the  translation of JSON Schema to XSD ?

Thanks,
rk

Roy Walmsley

unread,
Feb 8, 2017, 2:28:21 PM2/8/17
to JSON Schema
Hi,

You should be aware that the expressive powers of JSON schema are different to, and, in my opinion, better than those of XML schema. For example, I work with the 3D graphics standard X3D. This has a published XML encoding, with XSD schema, and a draft JSON encoding, with JSON schema. When developing the JSON schema I found that JSON offered better validation capabilities than the XML. I will give two examples:

1) Consider an object, which has multiple properties, which properties have values which are also objects. JSON schema can validate the content of each property individually. XML schema (XSD) can only validate the combined content objects.

2) Consider an object with a property holding an array. JSON can individually validate each array element. XML schema cannot.

So I conclude that JSON schema may not always be directly transformed to XML schema, and then back to a JSON schema, using automated tools, without loss of capability.

Roy

codebug

unread,
Feb 8, 2017, 5:59:10 PM2/8/17
to JSON Schema
Thank you Roy.

 Any idea about the open source libraries or any schema matching techniques for the conversion of XSD to Json Schema and vice-versa ?

Roy Walmsley

unread,
Feb 9, 2017, 1:21:00 PM2/9/17
to json-...@googlegroups.com
Hi,

No, sorry. Because our XSD schema is very complex, we first of all manually generated a JSON schema (using XMLSpy to do it graphically). Since then we used XSLT to generate an XML encoded object model for X3D. Then another XSLT to work generate the JSON schema. This latter is still a work in progress.

Roy

--
You received this message because you are subscribed to a topic in the Google Groups "JSON Schema" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/json-schema/mS0zP5nqGDo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to json-schema+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

codebug

unread,
Feb 10, 2017, 4:28:10 AM2/10/17
to JSON Schema
Thanks again :)

XSLT is like a happy ending but it isn't..Hard coding :D


On Thursday, February 9, 2017 at 7:21:00 PM UTC+1, Roy Walmsley wrote:
Hi,

No, sorry. Because our XSD schema is very complex, we first of all manually generated a JSON schema (using XMLSpy to do it graphically). Since then we used XSLT to generate an XML encoded object model for X3D. Then another XSLT to work generate the JSON schema. This latter is still a work in progress.

Roy
On 8 February 2017 at 22:59, codebug <katragadd...@gmail.com> wrote:
Thank you Roy.

 Any idea about the open source libraries or any schema matching techniques for the conversion of XSD to Json Schema and vice-versa ?


On Wednesday, February 8, 2017 at 8:28:21 PM UTC+1, Roy Walmsley wrote:
Hi,

You should be aware that the expressive powers of JSON schema are different to, and, in my opinion, better than those of XML schema. For example, I work with the 3D graphics standard X3D. This has a published XML encoding, with XSD schema, and a draft JSON encoding, with JSON schema. When developing the JSON schema I found that JSON offered better validation capabilities than the XML. I will give two examples:

1) Consider an object, which has multiple properties, which properties have values which are also objects. JSON schema can validate the content of each property individually. XML schema (XSD) can only validate the combined content objects.

2) Consider an object with a property holding an array. JSON can individually validate each array element. XML schema cannot.

So I conclude that JSON schema may not always be directly transformed to XML schema, and then back to a JSON schema, using automated tools, without loss of capability.

Roy

--
You received this message because you are subscribed to a topic in the Google Groups "JSON Schema" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/json-schema/mS0zP5nqGDo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to json-schema...@googlegroups.com.

kilapar...@gmail.com

unread,
Sep 4, 2017, 6:45:45 AM9/4/17
to JSON Schema, rajashekh...@gmail.com
Hi Raja,

please send me some reference fro xsd2json conversion.

Ben Hutton (@Relequestual)

unread,
Sep 4, 2017, 6:47:27 AM9/4/17
to JSON Schema, rajashekh...@gmail.com, kilapar...@gmail.com
JSON Schema is not intended to be feature equivalent with XML Schema. There are features in one but not in the other.

Resulting JSON Schema is likely to require manual editing. This is most likely not something you can automate.

John Carlson

unread,
Sep 5, 2017, 1:41:47 PM9/5/17
to JSON Schema
We nearly have a python "XML encoded object model to JSON schema converter".  Just need to handle some specific corner cases I hope that the object model assumes.    We have over 7000 documents in our test suite, and nearly 200 are failing (some are buggy or apply to a different schema that we haven't converted yet).  We have very specific data types (arrays, nodes) that would need to be converted to your use case.
To unsubscribe from this group and all its topics, send an email to json-schema...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages