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.1, < 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.2.tar.gz (262.1 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.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: as_dict_rec-0.1.2.tar.gz
  • Upload date:
  • Size: 262.1 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.2.tar.gz
Algorithm Hash digest
SHA256 5752b53e173d8255b554ee8382a9f5c30963d21c839e2b0e357cd69bc9244ed5
MD5 1ba88086cac486707098065656e89eba
BLAKE2b-256 b765fb952d0f79bb2cc01d6efc311e4616047083bc033d1b3fd00f513f0800c5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: as_dict_rec-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 177335b332e25c69733715d9baab1ab6b10a24c8ed642003eaa7d7a47e33f0b3
MD5 8369be8b79143c427599f91144895d04
BLAKE2b-256 13b1892ed820a806788cfa2ab20bb57d7e5c2573304535e93c355748f9d3e8cf

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