json-relational


Namejson-relational JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/gr0vity-dev/json-relational
Summaryconvert nested json to flat objects and their mapping
upload_time2024-02-07 09:38:23
maintainer
docs_urlNone
authorgr0vity
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

```bash
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:

```python
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.

```json
{
    "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](https://github.com/gr0vity-dev/json-relational/issues).

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/gr0vity-dev/json-relational",
    "name": "json-relational",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "gr0vity",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/3a/90/90b927ffdfb835f3c0f157bba4b9f518c371042204f0806758e5970ce1d0/json_relational-0.0.3.tar.gz",
    "platform": null,
    "description": "# json_relational: Transforming Nested JSON to Relational Format\n\n`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.\n\n## Features\n\n- **Dynamic Nesting Handling**: Effortlessly manages various levels of nested JSON data.\n- **SQL Table Ready**: Transforms JSON into a format that is easily convertible to SQL tables.\n- **Customizable Depth Control**: Set the maximum depth for flattening nested structures.\n- **Key Mapping Support**: Allows for the remapping of keys to desired names in the output.\n\n## Installation\n\nTo install `json_relational`, clone the repository from GitHub and install it using pip:\n\n```bash\ngit clone https://github.com/gr0vity-dev/json-relational.git\ncd json_relational\npip install .\n```\n\n## Usage\n\nHere's a simple example to demonstrate how `json_relational` can be used to transform nested JSON data into a relational format:\n\n```python\nfrom json_relational import JsonRelational\nimport json\n\n# Example JSON data\njson_data = {\n    \"type\": \"employee\",\n    \"id\": 123,\n    \"data\": {\n        \"department\": \"sales\",\n        \"manager\": \"Bob\"\n    }\n}\n\n# Create an instance of JsonRelational\njr = JsonRelational()\n\n# Flatten the JSON data\nflattened_data = jr.flatten_json(json_data)\n\nprint(json.dumps(flattened_data, indent=4))\n\n```\n\n### Output:\n\nThe output will be a dictionary containing flattened data, along with mappings and accumulated children, ready to be transformed into SQL tables.\n\n```json\n{\n    \"log\": [\n        {\n            \"sql_id\": 1,\n            \"type\": \"employee\",\n            \"id\": 123\n        }\n    ],\n    \"data\": [\n        {\n            \"sql_id\": 1,\n            \"department\": \"sales\",\n            \"manager\": \"Bob\"\n        }\n    ],\n    \"mappings\": [\n        {\n            \"main_type\": \"log\",\n            \"main_sql_id\": 1,\n            \"link_type\": \"data\",\n            \"link_sql_id\": 1\n        }\n    ]\n}\n```\n\n## Contributing\n\nContributions, issues, and feature requests are welcome! Feel free to check [issues page](https://github.com/gr0vity-dev/json-relational/issues).\n\n## License\n\nDistributed under the MIT License. See `LICENSE` for more information.\n\n---\n\n`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.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "convert nested json to flat objects and their mapping",
    "version": "0.0.3",
    "project_urls": {
        "Homepage": "https://github.com/gr0vity-dev/json-relational"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5630ae0fba0996fe9abac0b24a35ab62060cc3aa32be8455c1c04e395ed5d730",
                "md5": "8c1589d17b8cd823bdaa6049f3f77cea",
                "sha256": "8e66d50bfc518fdc8a2ef30df435b3ad4529b421aa69edc8bd7964193d7fda8b"
            },
            "downloads": -1,
            "filename": "json_relational-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8c1589d17b8cd823bdaa6049f3f77cea",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6032,
            "upload_time": "2024-02-07T09:38:22",
            "upload_time_iso_8601": "2024-02-07T09:38:22.184165Z",
            "url": "https://files.pythonhosted.org/packages/56/30/ae0fba0996fe9abac0b24a35ab62060cc3aa32be8455c1c04e395ed5d730/json_relational-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3a9090b927ffdfb835f3c0f157bba4b9f518c371042204f0806758e5970ce1d0",
                "md5": "baa3c2cb1d52b0bfa9c831dd73981738",
                "sha256": "4d90141bc33f437281f05da55dce80ac4b3301952b1dedacad411e7733b06b37"
            },
            "downloads": -1,
            "filename": "json_relational-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "baa3c2cb1d52b0bfa9c831dd73981738",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4590,
            "upload_time": "2024-02-07T09:38:23",
            "upload_time_iso_8601": "2024-02-07T09:38:23.855146Z",
            "url": "https://files.pythonhosted.org/packages/3a/90/90b927ffdfb835f3c0f157bba4b9f518c371042204f0806758e5970ce1d0/json_relational-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-07 09:38:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gr0vity-dev",
    "github_project": "json-relational",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "json-relational"
}
        
Elapsed time: 0.24179s