Provides the DataModelDict class for creating, accessing and manipulating json/xml data structures.
Project description
DataModelDict is a lightweight Python class for easy transformation and manipulation of JSON and XML structured data models. It is designed to take the best aspects of JSON, XML, and Python dictionaries to allow the user to interact with any of these formats in the same manner.
The code has no requirements that limit which systems it can be used on, i.e. it should work on Linux, Mac and Windows computers.
The latest release can be installed using pip:
pip install DataModelDict
The code and all documentation is hosted on GitHub and can be directly downloaded at https://github.com/usnistgov/DataModelDict.
Basic examples can be found in the Jupyter Notebook DataModelDict Basics.ipynb. Full documentation of the class methods can be found in Documentation.md.
The key features of DataModelDict (so far) are:
It is a child of OrderedDict meaning that it has all the features one would expect of a Python dictionary.
It has built-in conversion methods for reading and writing JSON and XML. JSON conversions use the standard Python json library and XML conversions use the xmltodict package.
Numbers (int, float) and key terms (True, False, None) are recognized and converted during parsing.
Methods for recusively searching the data model for specific keys and key-value pairs allow for the values and paths (as lists of indices) of elements to be easily found.
Path lists can also be directly used to get and set values.
#These two return the exact same val.
val = my_model['a']['b']['c']['d']
path = ['a', 'b', 'c', 'd']
val = my_model[path]
Additional methods for simplified handling of cases where XML does not directly map to JSON and Python dictionaries.
DataModelDict works by parsing in a JSON or XML data model such that every dictionary level is an instance of DataModelDict. This allows for the conversion and functional methods to be callable both on the full model and on subcomponents.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file DataModelDict-0.8.1.tar.gz
.
File metadata
- Download URL: DataModelDict-0.8.1.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4515a79b64f0a67844d6f2c17d625db2d7f5d168545884eda1f28aa58bdf1b31 |
|
MD5 | 0e5a85db8dc346ae47f02cb4947e8bf0 |
|
BLAKE2b-256 | d2f0e0492c7315d50d83371f17795c829b525e9b32bf030fdd5c974ef6389e61 |
File details
Details for the file DataModelDict-0.8.1-py2-none-any.whl
.
File metadata
- Download URL: DataModelDict-0.8.1-py2-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07ae8cad9fbd1c5a71fee1462c0cdd40e985238a0ad6ede11c1e0cf4970b97f5 |
|
MD5 | eed4434cb433d6015190f11d7bf9ff23 |
|
BLAKE2b-256 | e1ede7b7a675753a7900cc12468bf81279af75ab8baa5e53596f146d415f5dc9 |