Skip to content

Commit ef7cc47

Browse files
committed
documentation about ValidationException#toJSON() in README
1 parent 5beae14 commit ef7cc47

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* [Maven installation](#maven-installation)
55
* [Quickstart](#quickstart)
66
* [Investigating failures](#investigating-failures)
7+
* [JSON report of the failures](#json-report-of-the-failures)
78
* [Format validators](#format-validators)
89
* [Example](#example)
910
* [Resolution scopes](#resolution-scopes)
@@ -143,7 +144,18 @@ This will print the following output:
143144
#/rectangle/a: -5.0 is not higher or equal to 0
144145
#/rectangle/b: expected type: Number, found: String
145146
```
146-
147+
### JSON report of the failures
148+
149+
Since version `1.4.0` it is possible to print the `ValidationException` instances as
150+
JSON-formatted failure reports. The `ValidationException#toJSON()` method returns a `JSONObject` instance with the
151+
following keys:
152+
153+
* `"message"`: the programmer-friendly exception message (desription of the validation failure)
154+
* `"keyword"`: the JSON Schema keyword which was violated
155+
* `"pointerToViolation"`: a JSON Pointer denoting the path from the input document root to its fragment which caused
156+
the validation failure
157+
* `"causingExceptions"`: a (possibly empty) array of sub-exceptions. Each sub-exception is represented as a JSON object,
158+
with the same structure as described in this listing. See more above about causing exceptions.
147159

148160

149161
## Format validators
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)