json_relational: Transforming Nested JSON to Relational Format
json_relational is a small Python package for converting complex, nested JSON data into a flat, relational format. This transformation makes it significantly easier to work with JSON data in contexts where relational databases are more suitable, such as SQL databases. The package is designed to be dynamic and flexible, accommodating various levels of nested structures and converting them into a format that can be easily mapped to SQL tables.
Features
- Dynamic Nesting Handling: Effortlessly manages various levels of nested JSON data.
- SQL Table Ready: Transforms JSON into a format that is easily convertible to SQL tables.
- Customizable Depth Control: Set the maximum depth for flattening nested structures.
- Key Mapping Support: Allows for the remapping of keys to desired names in the output.
Installation
To install json_relational, clone the repository from GitHub and install it using pip:
git clone https://github.com/gr0vity-dev/json-relational.git
cd json_relational
pip install .
Usage
Here's a simple example to demonstrate how json_relational can be used to transform nested JSON data into a relational format:
from json_relational import JsonRelational
import json
# Example JSON data
json_data = {
"type": "employee",
"id": 123,
"data": {
"department": "sales",
"manager": "Bob"
}
}
# Create an instance of JsonRelational
jr = JsonRelational()
# Flatten the JSON data
flattened_data = jr.flatten_json(json_data)
print(json.dumps(flattened_data, indent=4))
Output:
The output will be a dictionary containing flattened data, along with mappings and accumulated children, ready to be transformed into SQL tables.
{
"log": [
{
"sql_id": 1,
"type": "employee",
"id": 123
}
],
"data": [
{
"sql_id": 1,
"department": "sales",
"manager": "Bob"
}
],
"mappings": [
{
"main_type": "log",
"main_sql_id": 1,
"link_type": "data",
"link_sql_id": 1
}
]
}
Contributing
Contributions, issues, and feature requests are welcome! Feel free to check issues page.
License
Distributed under the MIT License. See LICENSE for more information.
json_relational offers an innovative solution for managing and transforming JSON data into a relational structure, making it an invaluable tool for database management, data analysis, and software development involving complex JSON data structures.
Metadata
Release files for json-relational 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| json_relational-0.0.3.tar.gz | 4.6 kB | Without provenance | Details for json_relational-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| json_relational-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for json_relational-0.0.3-py3-none-any.whl |
Total release size: 10.6 kB
Release files / json_relational-0.0.3.tar.gz
| Download URL | json_relational-0.0.3.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d90141bc33f437281f05da55dce80ac4b3301952b1dedacad411e7733b06b37
|
|
BLAKE2b-256 checksum How to use checksums |
3a9090b927ffdfb835f3c0f157bba4b9f518c371042204f0806758e5970ce1d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.6
|
Release files / json_relational-0.0.3-py3-none-any.whl
| Download URL | json_relational-0.0.3-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e66d50bfc518fdc8a2ef30df435b3ad4529b421aa69edc8bd7964193d7fda8b
|
|
BLAKE2b-256 checksum How to use checksums |
5630ae0fba0996fe9abac0b24a35ab62060cc3aa32be8455c1c04e395ed5d730
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.6
|
Security for json-relational 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.