10000 GitHub - andrejserafim/json-schema: JSON Schema validator for java, based on the org.json API
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

andrejserafim/json-schema

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON Schema Validator

This project is an implementation of the JSON Schema Core Draft v4 specification. It uses the org.json API for representing JSON data.

Maven installation

Add the following to your pom.xml:

<dependency>
    <groupId>org.everit.json</groupId>
    <artifactId>org.everit.json.schema</artifactId>
    <version>1.0.0</version>
</dependency>

Quickstart

import org.everit.json.schema.Schema;
import org.everit.json.schema.loader.SchemaLoader;
import org.json.JSONObject;
import org.json.JSONTokener;
// ...
try (InputStream inputStream = getClass().getResourceAsStream("/path/to/your/schema.json")) {
  JSONObject rawSchema = new JSONObject(new JSONTokener(inputStream));
  Schema schema = SchemaLoader.load(rawSchema);
  schema.validate(new JSONObject("{\"hello\" : \"world\"}")); // throws a ValidationException if this object is invalid
}

About

JSON Schema validator for java, based on the org.json API

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%
0