Skip navigation links

json-schema-core 1.2.8 API

What this is

See: Description

Packages 
Package Description
com.github.fge.jsonschema  
com.github.fge.jsonschema.core.exceptions
Exceptions and exception provider
com.github.fge.jsonschema.core.keyword.syntax  
com.github.fge.jsonschema.core.keyword.syntax.checkers
Keyword syntax checkers
com.github.fge.jsonschema.core.keyword.syntax.checkers.common
Keyword syntax checkers common to both draft v3 and draft v4
com.github.fge.jsonschema.core.keyword.syntax.checkers.draftv3
Keyword syntax checkers specific to draft v3
com.github.fge.jsonschema.core.keyword.syntax.checkers.draftv4
Keyword syntax checkers specific to draft v4
com.github.fge.jsonschema.core.keyword.syntax.checkers.helpers
Keyword syntax checker helper classes
com.github.fge.jsonschema.core.keyword.syntax.checkers.hyperschema
Syntax checkers for draft v4 hyperschema keywords
com.github.fge.jsonschema.core.keyword.syntax.dictionaries  
com.github.fge.jsonschema.core.load
Schema loading and JSON Reference resolving
com.github.fge.jsonschema.core.load.configuration
Schema loading configuration
com.github.fge.jsonschema.core.load.download
URI downloader interface and provided implementations
com.github.fge.jsonschema.core.load.uri
URI translation
com.github.fge.jsonschema.core.messages  
com.github.fge.jsonschema.core.processing
Core processing interface and building utility classes
com.github.fge.jsonschema.core.ref
JSON Reference related classes
com.github.fge.jsonschema.core.report
Processing report infrastructure
com.github.fge.jsonschema.core.tree
Navigable JSON tree representations
com.github.fge.jsonschema.core.tree.key
JSON Schema keys (unique identifiers)
com.github.fge.jsonschema.core.util
Various utility classes
com.github.fge.jsonschema.core.util.equivalence  

What this is

This package provides an infrastructure to chain individual units of work (processors) together in order to produce arbitrarily complex processing chains. The provided infrastructure is complete with processing messages, reports and dedicated exceptions.

In addition, it also provides a basic set of structures to work with JSON Schema: trees and schema trees, JSON Reference, schema syntax validation and schema walking (with associated listeners and processors), schema loading.

Processors

Basics

A Processor is a base unit of work. Its concept is pretty simple: it accepts an input as an argument and produces an output.

For reporting purposes, it also has a ProcessingReport as an argument, to which you can log messages.

All the processing infrastructure is in the following package: jsonschema.core.processing.

Combining processors

You can combine processors in several ways:

You can therefore create arbitrarily complex chains. And, last but not least, you also have the ability to transparently cache the results of a processor if the computation is expensive, for future reuse -- not only that, but you can also provide an Equivalence on inputs to reduce the set of inputs cached.

Reporting/logging

Basics

The two basic components of the reporting/logging infrastructure are ProcessingReport and ProcessingMessage.

The existing infrastructure allows you to:

All the logging infrastructure is in the following package: jsonschema.core.report.

Reports

A processing report has a classical set of logging methods, which names will be familiar to anyone having used a logging API: debug(), info(), warn() and error(). You can customize what log levels are effectively logged, but also from what level exceptions are thrown instead.

As ProcessingReport is an interface, you can actually use a logging system for your messages -- or even log messages at different levels differently; however, be aware that the contract is rather strict (but it is documented), and as such you may prefer to extend AbstractProcessingReport instead.

This package comes with three implementations built in: ConsoleProcessingReport (which logs to the standard output), ListProcessingReport (which accumulates messages in a list} and DevNullProcessingReport (which discards all messages but keeps track of the processing status).

Messages

Messages have one main source: processor inputs. You will have noticed that both inputs and outputs are required to implement the MessageProvider interface: this allows reporting message templates to be generated out of an input and, as such, helps greatly in identifying what the source of the message is, and therefore at what step in the processing this message has been issued.

Another customization of logging messages is exception generation: when the message is logged at a level which raises an exception rather than being purely logged, AbstractProcessingReport does not throws per se, but calls this message's .asException() instead. If you have customized the processing message with a specific exception provider, this means your custom exception will be thrown rather than the standard ProcessingException.

JSON Reference

This package allows to build JSON References from string inputs or URI instances. You can also resolve one reference against another and obtain the fragment part (if the JSON Reference is legal) as a JSON Pointer.

The main use of this package in the core is to materialize URI contexts in JSON Schema instances. A special form (non URI compliant) of reference exists to be able to handle jar URIs as well.

All JSON Reference related classes are in the following package: jsonschema.core.ref.

Schema loading

Classes in the jsonschema.core.load package serve several purposes:

All aspects of schema loading are controlled via a LoadingConfiguration instance.

Regular expressions

JSON Schema requires that regular expressions obey the ECMA 262 regular expression dialect. This package, thanks to its dependency on Rhino, provides full compliance.

For this purpose, the RhinoHelper class allows you to test whether a string is a valid ECMA 262 regular expression, but also to test whether a string matches a given regex.

Skip navigation links