mirror of
https://github.com/justinrainbow/json-schema.git
synced 2025-05-05 14:06:23 +02:00
git-svn-id: https://jsonschemaphpv.svn.sourceforge.net/svnroot/jsonschemaphpv/trunk@2 14558f9d-7ea9-46ec-92da-52a2cad6a683
27 lines
572 B
PHP
27 lines
572 B
PHP
<?php
|
|
require_once('JsonSchema.php');
|
|
require_once('JsonSchemaUndefined.php');
|
|
Dbg::$quietMode = true;
|
|
|
|
if($_REQUEST['schema']) {
|
|
$schema = json_decode($_REQUEST['schema']);
|
|
if(!$schema) {
|
|
trigger_error('Could not parse the SCHEMA object.',E_USER_ERROR);
|
|
}
|
|
}
|
|
else {
|
|
$schema = null;
|
|
}
|
|
|
|
$json = json_decode($_REQUEST['json']);
|
|
if(!$json) {
|
|
trigger_error('Could not parse the JSON object.',E_USER_ERROR);
|
|
}
|
|
|
|
$result = JsonSchema::validate(
|
|
$json,
|
|
$schema
|
|
);
|
|
header('Content-type: application/x-json');
|
|
echo json_encode($result);
|
|
?>
|