index.rst 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. .. JsonSchema documentation master file, created by
  2. sphinx-quickstart on Sat Dec 10 15:34:44 2011.
  3. You can adapt this file completely to your liking, but it should at least
  4. contain the root `toctree` directive.
  5. Welcome to JsonSchema's documentation!
  6. ======================================
  7. Contents:
  8. .. toctree::
  9. :maxdepth: 2
  10. Installation
  11. ------------
  12. .. code-block:: console
  13. git clone --recursive https://github.com/justinrainbow/json-schema.git
  14. Composer method
  15. ^^^^^^^^^^^^^^^
  16. Add the `justinrainbow/json-schema` package to your `composer.json` file.
  17. .. code-block:: javascript
  18. {
  19. "require": {
  20. "justinrainbow/json-schema": ">=1.0.0-dev"
  21. }
  22. }
  23. Then just run the usual `php composer.phar install` to install.
  24. Usage
  25. -----
  26. .. code-block:: php
  27. <?php
  28. $validator = new JsonSchema\Validator();
  29. $result = $validator->validate(json_decode($json), json_decode($schema));
  30. if ($result->valid) {
  31. echo "The supplied JSON validates against the schema.\n";
  32. } else {
  33. echo "JSON does not validate. Violations:\n";
  34. foreach ($result->errors as $error) {
  35. echo "[{$error['property']}] {$error['message']}\n";
  36. }
  37. }
  38. Indices and tables
  39. ==================
  40. * :ref:`genindex`
  41. * :ref:`modindex`
  42. * :ref:`search`