Skip to main content

dict2rel

PyPI - Version PyPI - Python Version codecov

dict2rel is a Python library which can transform JSON with any level of nesting into one or more tables which contain enough information that the tables can be modified and then converted back to the nested JSON format. Essentially, JSON can be converted to relational tables and then back.


Table of Contents

Installation

pip install dict2rel

Quick Start

from dict2rel import dict2rel
import pandas as pd  # you can also use polars.DataFrame

tables = dict2rel(
    [
        {
            "name": "relay-settings",
            "version": {
                "major": 1,
                "minor": 12,
                "patch": 1
            },
            "settings": [
                {
                    "key": "tempo",
                    "value": 12
                },
                {
                    "key": "delay",
                    "value": 14
                }
            ]
        },
        {
            "name": "response-settings",
            "version": {
                "major": 12,
                "minor": 0,
                "patch": 3
            },
            "settings": [
                {
                    "key": "throttle",
                    "value": "always"
                },
                {
                    "key": "burst",
                    "value": 0.43
                }
            ]
        },
    ],
    pd.DataFrame  # the tables will be of this type
)

tables will end up being a dict of the following tables:

*

name version.major version.minor version.patch _id
relay-settings 1 12 1 0
response-settings 12 0 3 1

*.settings

key value _id
tempo 12 0.settings.0
delay 14 0.settings.1
throttle always 1.settings.0
burst 0.43 1.settings.1

These tables can then be modified, maybe by adding a new column:

tables["*.settings"]["added"] = ["2025-12-18"] * len(tables["*.settings"])

and then converted back to nested JSON:

from dict2rel import rel2dict

transformed_data = rel2dict(tables)

which gives the following JSON:

[
    {
        "name": "relay-settings", 
        "version": {"major": 1, "minor": 12, "patch": 1}, 
        "settings": [
            {"key": "tempo", "value": 12, "added": "2025-12-18"}, 
            {"key": "delay", "value": 14, "added": "2025-12-18"}
        ]
    }, 
    {
        "name": "response-settings", 
        "version": {"major": 12, "minor": 0, "patch": 3}, 
        "settings": [
            {"key": "throttle", "value": "always", "added": "2025-12-18"}, 
            {"key": "burst", "value": 0.43, "added": "2025-12-18"}
        ]
    }
]

License

dict2rel is distributed under the terms of the MIT license.

Development

Make sure to run hatch fmt, hatch run black:run, hatch run test:run, and hatch run docs:build.

Metadata

Release files for dict2rel 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dict2rel 0.0.3
File Size Uploaded Provenance Actions
dict2rel-0.0.3.tar.gz 19.6 kB With provenance Details for dict2rel-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dict2rel 0.0.3
File Interpreter ABI Platform Actions
dict2rel-0.0.3-py3-none-any.whl Python 3 none any Details for dict2rel-0.0.3-py3-none-any.whl

Total release size: 33.3 kB

Release files / dict2rel-0.0.3.tar.gz

Download URL dict2rel-0.0.3.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
51ce9911ec281a0e09c663344487161c7f54c863f4b9b78d6078f01f69cd01b4
BLAKE2b-256 checksum
How to use checksums
d6f8459c29ae9da0ca75476aa1f0fea3d1ab465b151201c51017df068089a0d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 25, 2025.

Transparency log

Release files / dict2rel-0.0.3-py3-none-any.whl

Download URL dict2rel-0.0.3-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b3886dbec28a185f210d8c79e67347aa6c9563146b66f862a1a613be34398eb
BLAKE2b-256 checksum
How to use checksums
0d6d365f8ba8c3f47c027b4d782bbcc48b89438d6bf02d2bd5868b9d46a3229c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 25, 2025.

Transparency log

Security for dict2rel 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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dict2rel-0.0.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 25, 2025.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page