Implements sereval JSON specs, like JSON Schema.
Project description
This library implements several JSON specs, like JSON Schema, JSON Reference and JSON Pointer:
It works on python 2.7, python 3.3 and above
It is release under the BSD license
Installation
This library has no special dependencies. You can simply use pip:
$ pip install json-extensions
Usage
Let say you want to fetch / validate JSON like objects.
You can extract member of an object with JSON Pointer:
from json.pointer import extract obj = { 'foo': ['bar', 'baz', 'quux'] } assert 'baz' == extract(obj, '/foo/1')
You can resolve member of any object with JSON Reference:
from json.reference import resolve obj = { 'foo': ['bar', 'baz', { '$ref': '#/sub' }], 'sub': 'quux' } assert 'quux' == resolve(obj, '#/foo/2')
You can describe you data with JSON Schema:
from json.schema import load # data will validate against this schema validator = load({ 'title': 'Example Schema', 'type': 'object', 'properties': { 'age': { 'description': 'Age in years', 'minimum': 0, 'type': 'integer' }, 'firstName': { 'type': 'string' }, 'lastName': { 'type': 'string' } }, 'required': [ 'firstName', 'lastName' ] }) # validate this data validator.validate({ 'firstName': 'John', 'lastName': 'Noone', 'age': 33, })
Other examples can be found in the documentation or in the tests.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for json-extensions-0.2.1.9.g9d1a9cb.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 931189b7682c2454b17cdfcaf72fa4ef96d210d3664095f7143de5512b5ee933 |
|
MD5 | 112d9b533f959b24eea8523b04dc7ee2 |
|
BLAKE2b-256 | d70b4ef1940cc2672d43f5a0034a6661698fd357612d9cfcfb12611048b0dfa0 |