jddf-python 
Documentation on readthedocs.io: https://jddf.readthedocs.io
This package is a Python implementation of JSON Data Definition Format, a schema language for JSON.
Installation
Install this package using:
pip3 install jddf
Usage
Briefly, here's how you would use this package:
import Schema, Validator from jddf
import json
# jddf.Schema represents a JDDF Schema.
#
# You can parse a jddf.Schema from JSON using Schema.from_json in combination
# with the standard library's json module.
schema = Schema.from_json(json.loads("""
{
"properties": {
"name": { "type": "string" },
"age": { "type": "uint32" },
"phones": {
"elements": { "type": "string" }
}
}
}
"""))
# jddf.Validator validates inputted data against schemas, and returns a list of
# validation errors.
#
# The exact data in validation errors is part of the JDDF specification, so
# every implementation of JDDF, across all languages, return the same sort of
# validation errors.
validator = Validator()
# This input is ok -- it passes all of the rules of the schema. So no validation
# errors are returned.
errors_ok = validator.validate(schema, json.loads("""
{
"name": "John Doe",
"age": 43,
"phones": ["+44 1234567", "+44 2345678"]
}
"""))
print(errors_ok) # []
# This input has three problems, so three validation errors are returned.
errors_bad = validator.validate(schema, json.loads("""
{
"age": "43",
"phones": ["+44 1234567", 442345678]
}
"""))
print(len(errors_bad)) # 3
# "name" is required
#
# [{'instance_path': [], 'schema_path': ['properties', 'name']}]
print(errors_bad[0])
# "age" has wrong type
#
# [{'instance_path': ['age'], 'schema_path': ['properties', 'age', 'type']}]
print(errors_bad[1])
# "phones[1]" has wrong type
#
# [{'instance_path': ['phones', '1'], 'schema_path': ['properties', 'phones', 'elements', 'type']}]
print(errors_bad[2])
Metadata
Release files for jddf 0.1.2
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 |
|---|---|---|---|---|
| jddf-0.1.2.tar.gz | 8.3 kB | Without provenance | Details for jddf-0.1.2.tar.gz |
Release files / jddf-0.1.2.tar.gz
| Download URL | jddf-0.1.2.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a87d700f5c2350b2a27019e0d220b0fae26fa6dff5fce624c393ec6f3bfc457
|
|
BLAKE2b-256 checksum How to use checksums |
2240c9f8c06246310a69be05fd55e068bd53d5f9900e7e739f62c2adff50b6d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3
|
Security for jddf 0.1.2
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.