1. Go to this page and download the library: Download urbanminded/json-verifier library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
urbanminded / json-verifier example snippets
use JSONVerifier\Verifier;
$schema = [
// 'name' must be a string
'name' => 'string',
// 'age' is an optional key.
// if present it must be an integer.
'?age' => 'int',
// 'favouriteFood' is an optional key.
// if present it must be a string or null.
'?favouriteFood' => '?string',
// 'pets' must be an array of objects matching the
// prescribed shape.
'pets' => Verifier::arrayOf('string', [
'name' => 'string',
'species' => 'string'
])
];
$verifier = new Verifier();
$verifier->verifyObject($schema, [
'name' => 'Jason',
'favouriteFood' => null,
'pets' => [
'Dora',
['name' => 'Ruby', 'species' => 'cat'],
['name' => 'Byron', 'species' => 'cat'],
['name' => 'Mitzi', 'species' => 'cat'],
]
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.