1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
.. JsonSchema documentation master file, created by
sphinx-quickstart on Sat Dec 10 15:34:44 2011.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to JsonSchema's documentation!
======================================
Contents:
.. toctree::
:maxdepth: 2
Installation
------------
.. code-block:: console
git clone https://github.com/jsonrainbow/json-schema.git
Composer method
^^^^^^^^^^^^^^^
Add the `justinrainbow/json-schema` package to your `composer.json` file.
.. code-block:: javascript
{
"require": {
"justinrainbow/json-schema": "1.1.*"
}
}
Then just run the usual `php composer.phar install` to install.
Usage
-----
.. code-block:: php
<?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";
}
}
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
|