File: README.rst

package info (click to toggle)
python-jsonschema 0.2-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 96 kB
  • sloc: python: 678; makefile: 6
file content (27 lines) | stat: -rw-r--r-- 805 bytes parent folder | download
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
==========
jsonschema
==========

``jsonschema`` is an implementation of JSON Schema (currently in `Draft 3
<http://tools.ietf.org/html/draft-zyp-json-schema-03>`_) for Python.

.. code:: python

    >>> from jsonschema import validate

    >>> # A sample schema, like what we'd get from json.load()
    >>> schema = {
    ...     "type" : "object",
    ...     "properties" : {
    ...         "price" : {"type" : "number"},
    ...         "name" : {"type" : "string"},
    ...     },
    ... }

    >>> # If no exception is raised by validate(), the instance is valid.
    >>> validate({"name" : "Eggs", "price" : 34.99}, schema)

    >>> validate({"name" : "Eggs", "price" : "Invalid"}, schema)
    Traceback (most recent call last):
        ...
    ValidationError: 'Invalid' is not of type 'number'