Breadcrumbs

Json Schema

Json Schema Validation

JsonValidation offers operations to validate a json document against a JSON schema, which is provided as in-memory String or reference to a file. Both operations return an array of SchemaValidationError instances. If that array is NULL or empty, the document is valid.

Json Schema Overview.png

Json Schema to XSD Converter

This tool is based on GitHub - ethlo/jsons2xsd: Highly configurable converter from JSON-schema to XML-schema (XSD) with some additions and tweaks. It will attempt to convert a given Json Schema into an equivalent XSD. So in combination with any tool that generates/guesses a Json Schema from an example Json file, this produces something that you can import into the PAS Builder.

It comes as a pre-packaged Java command-line application.

Command Line Interface

Usage: jsons2xsd [-hV] [--debug] [--includeUnused] [--noIndent] [--validate]
                 [--wrapArrays] -N=<namespace> [-R=<rootElement>] -T=<typeName>
                 <jsonSchemaFile> <xsdFile>
Converts a JSON schema to an equivalent XSD to be imported by PAS Builder,
based on https://github.com/ethlo/jsons2xsd
*     <jsonSchemaFile>   the source file containing the JSON schema
*     <xsdFile>          the target file containing the converted XSD
* -N, --namespace=<namespace>
                         the target namespace to set in the XSD
* -T, --typeName=<typeName>
                         the name of the complex XSD type to generate
  -R, --rootElement=<rootElement>
                         generate XSD root element with the give name
      --wrapArrays       wrap arrays in anonymous types
      --includeUnused    include types not referenced
      --noIndent         no indentation on output XSD
      --validate         validate the generated XSD for correctness
      --debug            prints debug messages while processing JSON schema
  -h, --help             Show this help message and exit.
  -V, --version          Print version information and exit.

Disclaimer

There is certainly a number of features in Json Schema that do not translate into anything that could be modeled in an XSD. Use at your own risk. The tool proved to be quite useful in a recent project at Coutts Bank for converting a rather large Json Schema.

📗

Related Pages:

📘