https://github.com/harrel56/json-schema
JSON schema validation library written in Java
https://github.com/harrel56/json-schema
java json json-schema jsonschema schema validation validator
Last synced: 4 months ago
JSON representation
JSON schema validation library written in Java
- Host: GitHub
- URL: https://github.com/harrel56/json-schema
- Owner: harrel56
- License: mit
- Created: 2023-02-06T20:09:14.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2025-03-25T20:41:24.000Z (12 months ago)
- Last Synced: 2025-03-25T21:30:42.773Z (12 months ago)
- Topics: java, json, json-schema, jsonschema, schema, validation, validator
- Language: Java
- Homepage: https://harrel.dev/json-schema
- Size: 1.94 MB
- Stars: 22
- Watchers: 2
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json-schema
[](https://github.com/harrel56/json-schema/actions/workflows/tests.yml)
[](https://mvnrepository.com/artifact/dev.harrel/json-schema)
[](https://javadoc.io/doc/dev.harrel/json-schema)
[](https://sonarcloud.io/summary/new_code?id=harrel56_json-schema)
[](https://jarhell.harrel.dev/packages/dev.harrel:json-schema)
[](https://jarhell.harrel.dev/packages/dev.harrel:json-schema)
[](https://jarhell.harrel.dev/packages/dev.harrel:json-schema)
Documentation: https://harrel56.github.io/json-schema
Java library implementing [JSON schema specification](https://json-schema.org/specification.html):
- compatible with Java 8,
- support for all recent [specification versions](https://harrel56.github.io/json-schema/dialects.html) [](https://bowtie.report/#/implementations/java-json-schema):
- Draft 2020-12 [](https://bowtie.report/#/dialects/draft2020-12),
- Draft 2019-09 [](https://bowtie.report/#/dialects/draft2019-09),
- Draft 07 [](https://bowtie.report/#/dialects/draft7),
- Draft 06 [](https://bowtie.report/#/dialects/draft6),
- Draft 04 [](https://bowtie.report/#/dialects/draft4),
- support for [custom keywords](https://harrel56.github.io/json-schema/evaluators.html),
- support for annotation collection,
- support for [format validation](https://harrel56.github.io/json-schema/format-validation.html) (for a price of one additional dependency 😉),
- compatible with most of the JSON/YAML libraries ([supported libraries](https://harrel56.github.io/json-schema/json-yaml-providers.html)),
- and no additional dependencies on top of that.
Check how it compares with other implementations:
- [Bowtie](https://bowtie.report) - specification compliance (only mandatory behavior),
- [Creek's benchmark](https://www.creekservice.org/json-schema-validation-comparison/performance) - benchmark for JVM based implementations.
## Demo
You can check out how it works [here](https://harrel.dev/json-schema).
## Installation
Please note that you will also need to include at least one of the supported JSON provider libraries (see [JSON provider setup](https://harrel56.github.io/json-schema/json-yaml-providers.html)).
### Maven
```xml
dev.harrel
json-schema
1.8.2
```
### Gradle
```groovy
implementation 'dev.harrel:json-schema:1.8.2'
```
## Usage
To validate JSON against a schema, you just need to invoke:
```java
String schema = """
{
"type": "boolean"
}""";
String instance = "true";
boolean valid = new ValidatorFactory().validate(schema, instance).isValid();
```
## Documentation
For more details please visit the [documentation](https://harrel56.github.io/json-schema).