Extract from a JSON/dict only whats in the JSON Schema
Project description
===================
json-schema-reducer
===================
.. image:: https://travis-ci.org/peterbe/json-schema-reducer.svg?branch=master
:target: https://travis-ci.org/peterbe/json-schema-reducer
.. image:: https://badge.fury.io/py/json-schema-reducer.svg
:target: https://pypi.python.org/pypi/json-schema-reducer
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
============
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.1
* Tidying up loose ends
0.1.0
* First, hopefully, working version.
json-schema-reducer
===================
.. image:: https://travis-ci.org/peterbe/json-schema-reducer.svg?branch=master
:target: https://travis-ci.org/peterbe/json-schema-reducer
.. image:: https://badge.fury.io/py/json-schema-reducer.svg
:target: https://pypi.python.org/pypi/json-schema-reducer
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
============
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.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
Close
Hashes for json-schema-reducer-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1db4831985c6b702576f575caf1c2873082016db8862a8b17522bb61f466cff |
|
MD5 | e7e31e753da45480e8f0ecf71d279607 |
|
BLAKE2b-256 | eafb9a980e30a2da9b36c150f0629d68dfd7f29e399c2f9eb452695d6a23fec4 |
Close
Hashes for json_schema_reducer-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f61d559269027967e546104df8edb14685ef070bc3e58ff8a9a88f1386ab9668 |
|
MD5 | 6c25f946e1f2a9581f39f1d30da32540 |
|
BLAKE2b-256 | a0d90e4636104ec480316b7b8c1197895e91aab17df6c729f4638c934fbb22cf |