com.github.fge.jsonschema.examples
Class Example1

java.lang.Object
  extended by com.github.fge.jsonschema.examples.ExampleBase
      extended by 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:


Constructor Summary
Example1()
           
 
Method Summary
static void main(String... args)
           
 
Methods inherited from class com.github.fge.jsonschema.examples.ExampleBase
loadResource, printReport
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Example1

public Example1()
Method Detail

main

public static void main(String... args)
                 throws IOException,
                        ProcessingException
Throws:
IOException
ProcessingException


Copyright © 2014. All Rights Reserved.