title: JSON schema validator library in Java
body: <p>I have a restful web service(JAVA) which has to accept JSON requests. I have to first validate this JSON against a JSON schema that I have.
  I'm not sure what is the best JAVA library to validate JSON again JSON schemas.
  I have used <a href="https://github.com/fge/json-schema-validator" rel="noreferrer">json-schema-validator</a>-2.1.7 library but it has not been very helpful. Even thought my JSON is not a valid JSON I do not get any errors.</p>
  
  <p>Here is the code I use for json-schema-validator-2.1.7</p>
  
  <pre><code>InputStream jsonSchemaInputStream = Assessment.class.getClassLoader().getResourceAsStream("Schemas/AssessmentMetrics.json");
  ObjectMapper mapper = new ObjectMapper();
  
  // Allows to retrieve a JSONSchema object on various sources
  // supported by the ObjectMapper provided
  JSONSchemaProvider schemaProvider = new JacksonSchemaProvider(mapper);
  
  // Retrieves a JSON Schema object based on a file
  JSONSchema schema = schemaProvider.getSchema(jsonSchemaInputStream);
  
  // Validates a JSON Instance object stored in a file
  List&lt;String&gt; errors = schema.validate(contents);
  </code></pre>