How to convert XSD to JSON schema directly in Java

Viewed 7924
1 Answers

Follow below steps to directly transform XSD into JSON Schema using Jsonix library

  1. 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

  2. Open command prompt or linux shell and navigate to the above jar directory.

  3. 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

  4. Above step will generate two files in the current directory
    a. schema file (FOOD.jsonschema)
    b. mapping file (FOOD.js)

  5. The schema file with .jsonschema extenstion is the desired equivalent JSON Schema.

Related