This release is a pre-release and may not be stable for production use.
Json Spec
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 only weak dependencies. You can simply use pip:
$ pip install json-spec
Regading you needs, you can install more features. For example, this command will enable colorated messages:
$ pip install json-spec[cli]
This one will enable ip format for json schema:
$ pip install json-spec[ip]
…
CLI Usage
This module expose 2 cli commands.
json-extract will extract parts of your json document:
$ json-extract '#/foo/1' --document-json='{"foo": ["bar", "baz"]}'
$ echo '{"foo": ["bar", "baz"]}' | json-extract '#/foo/1'
$ json-extract '#/foo/1' --document-file=doc.json
$ json-extract '#/foo/1' < doc.json
json-validate will validate your document against a schema:
$ json-validate --schema-file=schema.json --document-json='{"foo": ["bar", "baz"]}'
$ echo '{"foo": ["bar", "baz"]}' | json-validate --schema-file=schema.json
$ json-validate --schema-file=schema.json --document-file=doc.json
$ json-validate --schema-file=schema.json < doc.json
Library usage
Let say you want to fetch / validate JSON like objects in you python scripts.
You can extract member of an object with JSON Pointer:
from jsonspec.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 jsonspec.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 jsonspec.validators 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.
Metadata
Release files for json-spec 0.9.7.2.g16a294b
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| json-spec-0.9.7.2.g16a294b.tar.gz | 144.0 kB | Without provenance | Details for json-spec-0.9.7.2.g16a294b.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| json_spec-0.9.7.2.g16a294b-py2.py3-none-any.whl | Details for json_spec-0.9.7.2.g16a294b-py2.py3-none-any.whl |
Total release size: 187.9 kB
Release files / json-spec-0.9.7.2.g16a294b.tar.gz
| Download URL | json-spec-0.9.7.2.g16a294b.tar.gz |
|---|---|
| Size | 144.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bc512c968e0b411680512b80182bb4db00d821ce03df20c83d5f4aa7a615d1b4
|
|
BLAKE2b-256 checksum How to use checksums |
59e51eb971b59acfcd9a9086c346ff240e83e01f8abd635a5eb208e892983182
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / json_spec-0.9.7.2.g16a294b-py2.py3-none-any.whl
| Download URL | json_spec-0.9.7.2.g16a294b-py2.py3-none-any.whl |
|---|---|
| Size | 43.8 kB |
|
SHA-256 checksum How to use checksums |
366b9c4b929d374e61d998125dc7f24ae19fd11e6272e661a19adbdfeb27d35e
|
|
BLAKE2b-256 checksum How to use checksums |
d9c77366c2bc4377d7f65b1dcd6be0b4470f99f9c0547c3924f629a2c7e7e82e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for json-spec 0.9.7.2.g16a294b
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.