Extract from a JSON/dict only whats in the JSON Schema
Project description
Extract from a JSON/dict only whats in the JSON Schema. Assumes that the JSON/dict you supply is valid according to the JSON Schema you also supply.
Installation
Simple install with pip:
pip install json-schema-reducer
How to use it
Suppose you have two files on disk: schema.json and mything.json. And suppose that the schema.json only lists the properties foo and bar but the file mything.json contains many more things:
>>> from json_schema_reducer import make_reduced_dict >>> make_reduced_dict('schema.json', 'mything.json') {'foo': 'value1', 'bar': 'value2'}
The arguments are flexible. You can also do this:
>>> make_reduced_dict(open('schema.json'), open('mything.json'))
Or this:
>>> make_reduced_dict(open('schema.json').read(), open('mything.json').read())
Or this:
>>> make_reduced_dict( ... json.load(open('schema.json')), ... json.load(open('mything.json')))
Runnings tests
Simply run:
python setup.py test
Version History
- 0.1.4
Universal wheel
- 0.1.3
Better, but basic, cli (e.g. --help)
Support for optional nested keys
- 0.1.2
Correct README restructured text
- 0.1.1
Tidying up loose ends
- 0.1.0
First, hopefully, working version.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for json-schema-reducer-0.1.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6fbe437361e0ec14f5c05daf752604834bd9abe5af9ab6bdcb05ea1f8df1df6 |
|
MD5 | 1d749989b42721b5b36e1e7db3b00813 |
|
BLAKE2b-256 | 28f61e2cc23d6379879b96c601fe3d0992585af37cc60cbd17de9ba4dc73d616 |
Hashes for json_schema_reducer-0.1.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41c674275c2650dadb7f8af1193640ca41eb863926985ecda5bfee93aef265c0 |
|
MD5 | 5fd2ec1ecca08aef6f7a09abda5a7c2d |
|
BLAKE2b-256 | 511a5ac1131dcffa1063a0e0ded04e1326ea5a98dcc76d763b3532ecb7c73cfd |