Contents:
git clone https://github.com/justinrainbow/json-schema.git
Add the justinrainbow/json-schema package to your composer.json file.
{
"require": {
"justinrainbow/json-schema": "1.1.*"
}
}
Then just run the usual php composer.phar install to install.
<?php
$validator = new JsonSchema\Validator();
$result = $validator->validate(json_decode($json), json_decode($schema));
if ($result->valid) {
echo "The supplied JSON validates against the schema.\n";
} else {
echo "JSON does not validate. Violations:\n";
foreach ($result->errors as $error) {
echo "[{$error['property']}] {$error['message']}\n";
}
}
genindex
modindex
search