ex

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Committer:
TMBOY
Date:
Tue Jul 18 16:27:22 2017 +0800
Revision:
44:c1d8923072ba
?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TMBOY 44:c1d8923072ba 1 <?php
TMBOY 44:c1d8923072ba 2 require(__DIR__ . '/../vendor/autoload.php');
TMBOY 44:c1d8923072ba 3
TMBOY 44:c1d8923072ba 4 $data = json_decode(file_get_contents('data.json'));
TMBOY 44:c1d8923072ba 5
TMBOY 44:c1d8923072ba 6 // Validate
TMBOY 44:c1d8923072ba 7 $validator = new JsonSchema\Validator;
TMBOY 44:c1d8923072ba 8 $validator->check($data, (object)['$ref' => 'file://' . realpath('schema.json')]);
TMBOY 44:c1d8923072ba 9
TMBOY 44:c1d8923072ba 10 if ($validator->isValid()) {
TMBOY 44:c1d8923072ba 11 echo "The supplied JSON validates against the schema.\n";
TMBOY 44:c1d8923072ba 12 } else {
TMBOY 44:c1d8923072ba 13 echo "JSON does not validate. Violations:\n";
TMBOY 44:c1d8923072ba 14 foreach ($validator->getErrors() as $error) {
TMBOY 44:c1d8923072ba 15 echo sprintf("[%s] %s\n", $error['property'], $error['message']);
TMBOY 44:c1d8923072ba 16 }
TMBOY 44:c1d8923072ba 17 }