Skip to main content

It is a simple utility to recursively convert objects to dictionaries

Project description

Object To Dictionary

obj-todict is a simple utility to recursively convert objects to dictionaries. This can be particularly useful for serializing complex nested objects into JSON-compatible dictionaries.

Features

  • Recursively converts objects, including nested lists and dictionaries, into dictionaries.
  • Handles custom objects by converting their __dict__ attributes.

Installation

You can install the package using pip:

pip install obj-todict

Usage

Here's a quick example to get you started:

from obj_todict import todict

class Example:
    def __init__(self, name, value):
        self.name = name
        self.value = value

example = Example('example', [1, 2, {'key': 'value'}])
print(todict(example))

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

obj_todict-0.1.0.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

obj_todict-0.1.0-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file obj_todict-0.1.0.tar.gz.

File metadata

  • Download URL: obj_todict-0.1.0.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.9.3-76060903-generic

File hashes

Hashes for obj_todict-0.1.0.tar.gz
Algorithm Hash digest
SHA256 46b514fdf2e4d030a42d63bbafee2f80a71bc25026c07e94f833c099f5b76710
MD5 3d4b49b0c03f73cd8b2419f9eae06033
BLAKE2b-256 b81a00a8c9db2a425650e2d9e53b17b4321ffafcb811f8a5daccca6a441e4ed3

See more details on using hashes here.

File details

Details for the file obj_todict-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: obj_todict-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.9.3-76060903-generic

File hashes

Hashes for obj_todict-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a332453ec9fed92ace80f79a2eef44ebce9b3b4d662ccfbfd3b1c04d24b03e9
MD5 4c2d22c46c57176f4532ddf0d0f54702
BLAKE2b-256 6d7d878ec80eb935fa6d71ada876ec5998b492b711350e2bdfcfdf3c8413d14a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page