Welcome to JSON Spec

This library implements tools inspired by several cleaver specifications around JSON.

Features:

jsonspec.cli:

Expose JSON Pointer , JSON Schema and JSON Patch to your console:

json extract '#/foo/1' --document-json='{"foo": ["bar", "baz"]}'
json validate --schema-file=schema.json < doc.json
cat doc.json | json add '#/foo/1' --fragment='{"foo": ["bar", "baz"]}'
jsonspec.pointer:
 

Implements JSON Pointer and Relative JSON Pointer, it offers a way to target a subelement.

jsonspec.reference:
 

Implements JSON Reference and offers a way to cross reference json documents.

jsonspec.operations:
 

Inspired by JSON Patch, it gives the ability to manipulate the document tree.

jsonspec.validators:
 

Implements JSON Schema, it adds the power of document validation.

Of course, it works for Python 2.7, Python 3.3 and Python 3.4.

from jsonspec.validators import load

# data will validate against this schema
validator = load({
    'type': 'object',
    'properties': {
        'firstName': {
            'type': 'string',
        },
        'lastName': {
            'type': 'string',
        },
        'age': {
            'type': 'integer'
        }
    },
    'required': ['firstName', 'lastName', 'age']
})

# validate this data
validator.validate({
    'firstName': 'John',
    'lastName': 'Noone',
    'age': 33,
})

Additional Information

If you can’t find the information you’re looking for, have a look at the index or try to find it using the search function: