# 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:
```python
pip install meta-json
```
Or clone the repository:
```console
git clone https://github.com/juangcr/meta_json.git
cd meta_json
python setup.py install
```
## Usage
```python
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.
```
```console
{
"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 (Single supported pattern in v0.0.2)
- YYYY/MM/DD
- DD-MM-YYYY
- DD/MM/YYYY
- MM-DD-YYYY
- MM/DD/YYYY
```python
meta.attributes # Returns a list with two elements: the grouped main keys
# and the rest of the subkeys alltogether.
```
```console
[
[
"name",
"contact",
"status"
],
[
"start_date",
"active",
"credits",
"due",
"remaining"
]
]
```
```python
meta.layers # Returns all keys grouped by layer depth.
```
```console
{
"layer_0" :[
"name",
"contact",
"status"
],
"layer_1": [
"start_date",
"active",
"credits"
],
"layer_2": [
"due",
"remaining"
]
]
```
Raw data
{
"_id": null,
"home_page": "https://github.com/juangcr/meta_json",
"name": "meta-json",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "metadata json",
"author": "Juan Cort\u00e9s",
"author_email": "juang.cortes@outlook.com",
"download_url": "",
"platform": null,
"description": "# meta_json\n\nGiven a JSON response as a dictionary, extract the metadata such as its structure and data model. \n\n\n## Introduction\n\nThis 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. \n\n\n## Installation\n\nThis package is available in PyPI and GitHub. Just run:\n\n```python\n pip install meta-json\n```\n\nOr clone the repository:\n\n```console\n git clone https://github.com/juangcr/meta_json.git \n cd meta_json\n python setup.py install\n```\n\n## Usage\n\n```python\n from meta_json import MetaJson\n \n your_json_data_as_dict = {\n \"name\": \"John Doe\",\n \"contact\": \"john_doe@mail.net\",\n \"status\": {\n \"start_date\": \"1970-01-01\",\n \"active\": \"true\",\n \"credits\": {\n \"due\": 10,\n \"remaining\": 90\n }\n }\n }\n\n meta = MetaJson(your_json_data_as_dict)\n \n meta.types # Returns every data type available.\n```\n\n```console\n {\n \"name\": \"str\",\n \"contact\": \"str\", \n \"status\": {\n \"start_date\": \"datetime\",\n \"active\": \"str\",\n \"credits\": {\n \"due\": \"int\",\n \"remaining\": \"int\"\n }\n }\n }\n```\n\nKeep in mind that the datetime recognition supports the following patterns:\n\n- YYYY-MM-DD (Single supported pattern in v0.0.2)\n- YYYY/MM/DD\n- DD-MM-YYYY\n- DD/MM/YYYY\n- MM-DD-YYYY\n- MM/DD/YYYY\n\n```python\n meta.attributes # Returns a list with two elements: the grouped main keys\n # and the rest of the subkeys alltogether.\n```\n\n```console\n [\n [\n \"name\",\n \"contact\",\n \"status\"\n ],\n [\n \"start_date\",\n \"active\",\n \"credits\",\n \"due\",\n \"remaining\"\n ]\n ]\n```\n\n```python\n meta.layers # Returns all keys grouped by layer depth.\n```\n\n```console\n {\n \"layer_0\" :[\n \"name\",\n \"contact\",\n \"status\"\n ],\n \"layer_1\": [\n \"start_date\",\n \"active\",\n \"credits\"\n ],\n \"layer_2\": [\n \"due\",\n \"remaining\"\n ]\n ]\n```\n\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "Extract metadata from a deserialized JSON.",
"version": "0.0.3",
"split_keywords": [
"metadata",
"json"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a3151c26a185446b66d545fc7f571b474d58f217fe740d99411a234b8b16bf96",
"md5": "7e584b274f167791671cfc717ac491e0",
"sha256": "081bea09ea389aae4c583e703d17b4b634e0950c2165be7d52fd2d816ace4602"
},
"downloads": -1,
"filename": "meta_json-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7e584b274f167791671cfc717ac491e0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 4459,
"upload_time": "2023-03-17T05:35:21",
"upload_time_iso_8601": "2023-03-17T05:35:21.491741Z",
"url": "https://files.pythonhosted.org/packages/a3/15/1c26a185446b66d545fc7f571b474d58f217fe740d99411a234b8b16bf96/meta_json-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-17 05:35:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "juangcr",
"github_project": "meta_json",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "meta-json"
}