Extract metadata from a deserialized JSON.
Project description
meta_json
Given a JSON response as a dictionary, extract the metadata such as its structure and data model.
Introduction
This package is intended to help with JSON analysis by extracting its metadata and ease the data modeling tasks regularly used in design of databases, data catalogs, data warehouses, APIs, etc.
Installation
This package is available in PyPI and GitHub. Just run:
pip install meta-json
Or clone the repository:
git clone https://github.com/juangcr/meta_json.git
cd meta_json
python setup.py install
Usage
from meta_json import MetaJson
your_json_data_as_dict = {
"name": "John Doe",
"contact": "john_doe@mail.net",
"status": {
"start_date": "1970-01-01",
"active": "true",
"credits": {
"due": 10,
"remaining": 90
}
}
}
meta = MetaJson(your_json_data_as_dict)
meta.types() # Returns every data type available.
{
"name": "str",
"contact": "str",
"status": {
"start_date": "datetime",
"active": "str",
"credits": {
"due": "int",
"remaining": "int"
}
}
}
Keep in mind that the datetime recognition supports the following patterns:
- YYYY-MM-DD
- YYYY/MM/DD
- DD-MM-YYYY
- DD/MM/YYYY
- MM-DD-YYYY
- MM/DD/YYYY
meta.attributes() # Returns a list with two elements: the grouped main keys
# and the rest of the subkeys alltogether.
[
[
"name",
"contact",
"status"
],
[
"start_date",
"active",
"credits",
"due",
"remaining"
]
]
meta.layers() # Returns all keys grouped by layer depth.
{
"layer_0" :[
"name",
"contact",
"status"
],
"layer_1": [
"start_date",
"active",
"credits"
],
"layer_2": [
"due",
"remaining"
]
]
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
meta_json-1.0.0.tar.gz
(9.5 kB
view details)
Built Distribution
File details
Details for the file meta_json-1.0.0.tar.gz
.
File metadata
- Download URL: meta_json-1.0.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2294de3d8f4a9659cbc4877a210d07ebb2de4e98e863ed630baf28629076a1be |
|
MD5 | d682006bcf3ea199c5500fae27a59bd1 |
|
BLAKE2b-256 | 05031739ceb2c9c893d47c0e77ca0a3058f2603b8dd0bed6f56bb95b7a334906 |
File details
Details for the file meta_json-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: meta_json-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7d0e530033f0e203872ded57b2c0538dc2e8559233186c00189811695e26e74 |
|
MD5 | b67e231c5daf0ddb32b3d065c256d27a |
|
BLAKE2b-256 | e034d9e2b54bf10813d07a823c41d4d83e0e6dbde7ac816905dd59d3140b7264 |