Skip to content

harrel56/json-schema

Repository files navigation

json-schema

build maven javadoc Coverage Size Bytecode Dependencies

Documentation: https://harrel56.github.io/json-schema

Java library implementing JSON schema specification:

  • compatible with Java 8,
  • support for all recent specification versions Supported spec:
    • Draft 2020-12 Compliance,
    • Draft 2019-09 Compliance,
    • Draft 07 Compliance,
    • Draft 06 Compliance,
    • Draft 04 Compliance,
  • support for custom keywords,
  • support for annotation collection,
  • support for format validation (for a price of one additional dependency 😉),
  • compatible with most of the JSON/YAML libraries (supported libraries),
  • and no additional dependencies on top of that.

Check how it compares with other implementations:

  • Bowtie - specification compliance (only mandatory behavior),
  • Creek's benchmark - benchmark for JVM based implementations.

Demo

You can check out how it works here.

Installation

Please note that you will also need to include at least one of the supported JSON provider libraries (see JSON provider setup).

Maven

<dependency>
    <groupId>dev.harrel</groupId>
    <artifactId>json-schema</artifactId>
    <version>1.8.2</version>
</dependency>

Gradle

implementation 'dev.harrel:json-schema:1.8.2'

Usage

To validate JSON against a schema, you just need to invoke:

String schema = """
        {
          "type": "boolean"
        }""";
String instance = "true";
boolean valid = new ValidatorFactory().validate(schema, instance).isValid();

Documentation

For more details please visit the documentation.

About

JSON schema validation library written in Java

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages