toobj


Nametoobj JSON
Version 0.0.1 PyPI version JSON
download
home_pagehttps://github.com/Jaldekoa/toobj
SummaryPython package that transforms flat or nested dictionaries into objects.
upload_time2024-10-14 12:32:40
maintainerNone
docs_urlNone
authorJon Aldekoa
requires_pythonNone
licenseNone
keywords
VCS
bugtrack_url
requirements setuptools pytest
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # toobj: Transform a dictionary into an object
Python package that transforms flat or nested dictionaries into objects.

## Installation
```commandline
pip install toobj
```

## ToObj
Transforms flat or nested dictionaries into objects.

### Args
| Parameter | Type   | Description                             |
|-----------|--------|-----------------------------------------|
| `d`       | `dict` | Dictionary to convert in Python object. |

```python
from toobj import ToObj

d = dict(...)
obj = ToObj(d)
```

## Usage

```python
from toobj import ToObj

# Sample data
data = {
    'name': 'Alice',
    'age': 30,
    'address': {
        'city': 'Wonderland',
        'zipcode': 12345,
        'coordinates': {
            'lat': 52.5200,
            'long': 13.4050,
            'meta': {
                'continent': 'Europe',
                'population': 3000000
            }
        }
    },
    'contacts': {
        'email': 'alice@example.com',
        'phones': [
            {'type': 'home', 'number': '123-456'},
            {'type': 'work', 'number': '789-101'}
        ]
    },
    'hobbies': ['reading', 'traveling', {'name': 'coding', 'level': 'advanced'}]
}

# Dictionary to object
data_obj = ToObj(data)
```

```
>>> data_obj.name
'Alice'
>>> data_obj.address.zipcode
12345
>>> data_obj.address.coordinates.meta.continent
'Europe'
>>> data_obj.contacts.phones[0].number
'123-456'
>>> data_obj.hobbies[2].name
'coding'
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Jaldekoa/toobj",
    "name": "toobj",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Jon Aldekoa",
    "author_email": "jaldekoa@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9d/25/debc9199acd2a5e46fcce3ca17000ebf2d8a1be1ab8cf2023da0dbee7c83/toobj-0.0.1.tar.gz",
    "platform": "Any",
    "description": "# toobj: Transform a dictionary into an object\nPython package that transforms flat or nested dictionaries into objects.\n\n## Installation\n```commandline\npip install toobj\n```\n\n## ToObj\nTransforms flat or nested dictionaries into objects.\n\n### Args\n| Parameter | Type   | Description                             |\n|-----------|--------|-----------------------------------------|\n| `d`       | `dict` | Dictionary to convert in Python object. |\n\n```python\nfrom toobj import ToObj\n\nd = dict(...)\nobj = ToObj(d)\n```\n\n## Usage\n\n```python\nfrom toobj import ToObj\n\n# Sample data\ndata = {\n    'name': 'Alice',\n    'age': 30,\n    'address': {\n        'city': 'Wonderland',\n        'zipcode': 12345,\n        'coordinates': {\n            'lat': 52.5200,\n            'long': 13.4050,\n            'meta': {\n                'continent': 'Europe',\n                'population': 3000000\n            }\n        }\n    },\n    'contacts': {\n        'email': 'alice@example.com',\n        'phones': [\n            {'type': 'home', 'number': '123-456'},\n            {'type': 'work', 'number': '789-101'}\n        ]\n    },\n    'hobbies': ['reading', 'traveling', {'name': 'coding', 'level': 'advanced'}]\n}\n\n# Dictionary to object\ndata_obj = ToObj(data)\n```\n\n```\n>>> data_obj.name\n'Alice'\n>>> data_obj.address.zipcode\n12345\n>>> data_obj.address.coordinates.meta.continent\n'Europe'\n>>> data_obj.contacts.phones[0].number\n'123-456'\n>>> data_obj.hobbies[2].name\n'coding'\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python package that transforms flat or nested dictionaries into objects.",
    "version": "0.0.1",
    "project_urls": {
        "Homepage": "https://github.com/Jaldekoa/toobj"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b0def9f64a26d2a8f42d8434e4d761afb4357afe21d655aa5c27071f4f9aa9ca",
                "md5": "f47afdfaec4b6a17e9dd8fa838ddcc81",
                "sha256": "e6fe1982e4f2a3a8b074503080fad4d3f761b2d1d3cb7ae32663e0285b63d5b9"
            },
            "downloads": -1,
            "filename": "toobj-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f47afdfaec4b6a17e9dd8fa838ddcc81",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14512,
            "upload_time": "2024-10-14T12:32:37",
            "upload_time_iso_8601": "2024-10-14T12:32:37.894891Z",
            "url": "https://files.pythonhosted.org/packages/b0/de/f9f64a26d2a8f42d8434e4d761afb4357afe21d655aa5c27071f4f9aa9ca/toobj-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9d25debc9199acd2a5e46fcce3ca17000ebf2d8a1be1ab8cf2023da0dbee7c83",
                "md5": "b59cf16c2f47569ff03a6d096753f106",
                "sha256": "7b99e5db88635acb68fd38b60399521237d2a9fbad9545a50f1dbcb04b89b7a4"
            },
            "downloads": -1,
            "filename": "toobj-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b59cf16c2f47569ff03a6d096753f106",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 14495,
            "upload_time": "2024-10-14T12:32:40",
            "upload_time_iso_8601": "2024-10-14T12:32:40.421879Z",
            "url": "https://files.pythonhosted.org/packages/9d/25/debc9199acd2a5e46fcce3ca17000ebf2d8a1be1ab8cf2023da0dbee7c83/toobj-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-14 12:32:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Jaldekoa",
    "github_project": "toobj",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "setuptools",
            "specs": [
                [
                    "~=",
                    "69.5.1"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "~=",
                    "8.1.1"
                ]
            ]
        }
    ],
    "lcname": "toobj"
}
        
Elapsed time: 0.41961s