Skip to main content

Reduce a complex Python structure to basic types

Project description

Reduce a complex Python structure to basic types

[Home | sourcehut | PyPI | ReadTheDocs]

Overview

The as-dict-rec Python library mainly provides the [as_dict_rec()][as_dict_rec.as_dict_rec] function that takes an arbitrarily complex Python data structure (a dictionary, a dataclass, a set of lists of complex numbers, etc) and converts it to a form that may be serialized into an e.g. JSON, TOML, or similar representation.

Installation

A program that uses the as-dict-rec library should specify it in its list of requirements, e.g. using PEP508 syntax:

as-dict-rec >= 0.1.10, < 0.2

Basic usage

Convert a structure to a JSON representation:

print(json.dumps(as_dict_rec.as_dict_rec(complex_data), indent=2))

Skip null values in lists, dictionaries, etc, since TOML cannot represent them:

print(tomli_w.dumps(as_dict_rec.as_dict_rec(complex_data, skip_null=True), indent=2))

Contact

The as-dict-rec library was written by Peter Pentchev. It is developed in a sourcehut repository. This documentation is hosted at Ringlet with a copy at ReadTheDocs.

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

as_dict_rec-0.1.1.tar.gz (173.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

as_dict_rec-0.1.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file as_dict_rec-0.1.1.tar.gz.

File metadata

  • Download URL: as_dict_rec-0.1.1.tar.gz
  • Upload date:
  • Size: 173.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for as_dict_rec-0.1.1.tar.gz
Algorithm Hash digest
SHA256 996a9d318fba7f8d68fb02a16fbfc3dc388333bacada0fcce532ebd8fd13f6a1
MD5 146b9cd0b171e04ed21ee52cfafb7165
BLAKE2b-256 5045ab2177e006cfeeaf928243ca67bd808022f24b44a7c7107f98fa6381cc22

See more details on using hashes here.

File details

Details for the file as_dict_rec-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: as_dict_rec-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for as_dict_rec-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 82727ab82f85256ef79058e8ede323db7e8a0d0769def06cdba74d035b741c55
MD5 8cc3006fb3af32eb09794e06f33a4590
BLAKE2b-256 015b44dec06e4d600f070228d9558f20e8496bd2d9a126e277794f5783a2aa48

See more details on using hashes here.

Supported by

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