vjson
0.1.0
vjson creates an object to serialize the only of the type specified in JSONSchema. It works like a json module.
install
Next, execute command.:
$ pip install vjson
How to use
You define an object using JSONSchema.:
>>> import vjson
>>> _json = vjson.ValidatedJSON({
... 'type': 'object',
... 'properties': {
... 'price': {'type': 'number'},
... 'name': {'type': 'string'},
... },
... })
This object can dumps/loads()/dump()/load() the serializable object, as in the json module.:
>>> _json.loads('{"name" : "Eggs", "price" : 34.99}')
{'name': 'Eggs', 'price': 34.99}
>>> _json.dumps({"name": "Eggs", "price": 34.99})
'{"name": "Eggs", "price": 34.99}'
If you try to pass the data that violates the JSONSchema that was specified in the constructor, it raises a vjson.JSONValidationError.:
>>> _json.loads('{"name" : "Eggs", "price" : "34.99"}')
Traceback (most recent call last):
File "/tmp/test/var/src/develop/vjson/src/vjson/__init__.py", line 32, in _wrap
jsonschema.validate(data, schema)
File "/tmp/test/env/lib/python3.4/site-packages/jsonschema/validators.py", line 478, in validate
cls(schema, *args, **kwargs).validate(instance)
File "/tmp/test/env/lib/python3.4/site-packages/jsonschema/validators.py", line 123, in validate
raise error
jsonschema.exceptions.ValidationError: '34.99' is not of type 'number'
Failed validating 'type' in schema['properties']['price']:
{'type': 'number'}
On instance['price']:
'34.99'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/test/var/src/develop/vjson/src/vjson/__init__.py", line 34, in _wrap
raise JSONValidationError(err)
vjson.JSONValidationError: '34.99' is not of type 'number'
Failed validating 'type' in schema['properties']['price']:
{'type': 'number'}
On instance['price']:
'34.99'
>>>
Metadata
Release files for vjson 0.1
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 | |
|---|---|---|---|---|
| vjson-0.1.tar.gz | 4.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vjson-0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.3 kB
Release files / vjson-0.1.tar.gz
| Download URL | vjson-0.1.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
84cf1f2e293fda30c255dcd338d1492822c478fbb00f162a0e5265b8863e818a
|
|
BLAKE2b-256 checksum How to use checksums |
e1283e0c609365ca5e6dd2d83e8d176a8393f09d22f51f53a02bbb847cc912c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / vjson-0.1-py3-none-any.whl
| Download URL | vjson-0.1-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fcfdaaba3ea858a096bdba68cdeaba7b0197b0514b07b796c2fc79ff93af914a
|
|
BLAKE2b-256 checksum How to use checksums |
4a495a0d31034da153362f9209752757819812f618d96fa527695140912f936a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for vjson 0.1
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.