try {
$string = $encoder->encode($data, '/path/to/schema.json');
} catch (ValidationFailedException $e) {
// data did not match schema
}
try {
$data = $decoder->decodeFile('/path/to/file.json', '/path/to/schema.json');
} catch (ValidationFailedException $e) {
// data did not match schema
}
See http://json-schema.org/examples.html
Example Encoding
Example Decoding