Reputation: 721
can anybody suggest how to convert XSD schema to JSON schema using Java?
I have tried so many ways, almost all the ways generating class files using com.fasterxml.jackson libraries and then converting it to JSON which is not possible in my case.
here are the links I have tried
https://dzone.com/articles/generating-json-schema-xsd
http://marxsoftware.blogspot.in/2015/06/json-schema-xsd-jaxb-jackson.html
Thanks in Advance.
Upvotes: 6
Views: 13062
Reputation: 1734
Follow below steps to directly transform XSD into JSON Schema using Jsonix library
Download jsonix schema compiler from here
The downloaded jar name would be something like below based on downloaded version
jsonix-schema-compiler-full-2.3.9.jar
Open command prompt or linux shell and navigate to the above jar directory.
Execute below command from this directory
java -jar jsonix-schema-compiler-full-2.3.9.jar -generateJsonSchema -p FOOD schemas/food.xsd
Note: in above command schemas/food.xsd
is the relative path of XSD schema file
Above step will generate two files in the current directory
a. schema file (FOOD.jsonschema)
b. mapping file (FOOD.js)
The schema file with .jsonschema extenstion is the desired equivalent JSON Schema.
Upvotes: 1