Is anyone aware of a tool or approach from which we can generate a JSON schema from XML schema or XML schema from JSON schema by Java?
Plugin for converting an XML Schema (XSD) file to a JSON Schema file. Once installed, go to Tools -> XML Actions, or right-click on an XML Schema file from Project view, and select "Convert XSD to JSON Schema".
A Schema object is thread safe and applications are encouraged to share it across many parsers in many threads. A Schema object is immutable in the sense that it shouldn't change the set of constraints once it is created.
In the same way that an XML Schema specifies the structure and content of an XML document, a JSON schema specifies how the JSON data in a JSON document is organized. It specifies what data fields are expected and how the values are represented.
Since JSON isn't there yet, the best option is to use one of the XML Schema languages. We can use an XSD to generate our Java object model. We can use the Java objects to export data into XML documents. We can even use the same Java objects to export the data into JSON documents.
It isn't very elegant, but jackson can generate json schema from a java class . So you could take your xml schema, generate java classes from it with jaxb annotations, then generate the json schema from that as jackson supports jaxb annotations.
If you can get POJOs that match Schema (using xjc for example), you could then use Jackson to produce JSON Schema (see ObjectMapper.generateSchema(...)).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With