com.github.fge.jsonschema.examples
Class Example4
java.lang.Object
com.github.fge.jsonschema.examples.Example4
public final class Example4
- extends Object
Fourth example: schema loading via URIs, and subschema addressing
link to source code
link to schema
This demonstrates two capabilities of JsonSchemaFactory
:
- the ability to Utils.load schemas via URIs;
- the ability to address subschemas in a schema.
The implementation provides a resource
scheme which allows to Utils.load
JSON from files in the classpath. It is strictly equivalent to calling Class.getResourceAsStream(String)
.
The URI used is resource:/org/eel/kitchen/jsonschema/examples/fstab-sub.json
. Because we
want to validate against the fstab
subschema, we use JsonSchemaFactory.getJsonSchema(String)
to Utils.load the actual schema; the URI
used as an argument also has a JSON Pointer as a fragment.
Files validated, and the validation outputs, are the same as for Example2
.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Example4
public Example4()
main
public static void main(String... args)
throws IOException,
ProcessingException
- Throws:
IOException
ProcessingException