Skip to main content

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:

  1. It is a child of OrderedDict meaning that it has all the features one would expect of a Python dictionary.

  2. 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.

  3. Numbers (int, float) and key terms (True, False, None) are recognized and converted during parsing.

  4. 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.

  5. 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]
  1. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

DataModelDict-0.8.zip (9.7 kB view details)

Uploaded Source

File details

Details for the file DataModelDict-0.8.zip.

File metadata

  • Download URL: DataModelDict-0.8.zip
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for DataModelDict-0.8.zip
Algorithm Hash digest
SHA256 c497ee3c894f963d19365b9ceeb31b97f5b4caa67bdd6aeabf4d67fc2724eecc
MD5 7a0be97cd38f8d7846aa6044073a5a91
BLAKE2b-256 00ee65b8384dec214670e264ffd352552da437b15dc8f9b43c81367429bbb6d0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page