com.github.fge.jsonschema.examples
Class Example1
java.lang.Object
com.github.fge.jsonschema.examples.ExampleBase
com.github.fge.jsonschema.examples.Example1
public final class Example1
- extends ExampleBase
First example: basic usage
link to source code
This shows a basic usage example. The schema used for validation is
here, which conforms to draft v4, which is
the default version. You will notice that a JSON Pointer (#/definitions/mntent
) is used to address a subschema defining a mount entry.
This example uses JsonSchemaFactory.byDefault()
, and uses
JsonSchemaFactory.getJsonSchema(JsonNode)
to create the JsonSchema
instance.
The first sample (here) validates
successfully.
The second sample (here) fails to
validate. Please note that the failure occurs at the structural level
(required entry swap
is missing). Validation therefore stops here,
and does not attempt to validate the /
member of the instance, which
is itself invalid.
The third sample (here) fails to
validate as well. This time, the problem is with the member values:
- the
options
member of /tmp
is a string, but an array
is expected;
- the
/
member is missing the required fstype
member.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Example1
public Example1()
main
public static void main(String... args)
throws IOException,
ProcessingException
- Throws:
IOException
ProcessingException
Copyright © 2014. All Rights Reserved.