File tree Expand file tree Collapse file tree 3 files changed +21
-4
lines changed
core/src/main/java/org/everit/jsonvalidator Expand file tree Collapse file tree 3 files changed +21
-4
lines changed Original file line number Diff line number Diff line change 1
- <img src =" https://travis-ci.org/erosb/json-schema-validator.svg?branch=master " />
2
-
3
1
JSON Schema Validator
2
+ =====================
3
+
4
+ This project is an implementation of the [ JSON Schema Core Draft v4] ( "http://json-schema.org/latest/json-schema-core.html" ) specification.
5
+ It uses the [ org.json API] ( "http://www.json.org/java/" ) for representing JSON data.
6
+
7
+ Quickstart
8
+ ----------
9
+
10
+ ``` java
11
+ import org.everit.jsonvalidator.Schema ;
12
+ import org.everit.jsonvalidator.loader.SchemaLoader ;
13
+ import org.json.JSONObject ;
14
+ import org.json.JSONTokener ;
15
+ // ...
16
+ JSONObject rawSchema = new JSONObject (new JSONTokener (Main . class. getResourceAsStream(" /path/to/your/schema.json" )));
17
+ Schema schema = SchemaLoader . load(rawSchema);
18
+ schema. validate(new JSONObject (" {\" hello\" : \" world\" }" )); // throws a ValidationException if this object is invalid
19
+ ```
20
+
4
21
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ public ReferenceSchema(final Builder builder) {
53
53
}
54
54
55
55
@ Override
56
- void validate (final Object subject ) {
56
+ public void validate (final Object subject ) {
57
57
if (referredSchema == null ) {
58
58
throw new IllegalStateException ("referredSchema must be injected before validation" );
59
59
}
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ protected Schema(final Builder builder) {
75
75
/**
76
76
* Validates.
77
77
*/
78
- abstract void validate (final Object subject );
78
+ public abstract void validate (final Object subject );
79
79
80
80
@ Override
81
81
public int hashCode () {
You can’t perform that action at this time.
0 commit comments