Metadata-Version: 2.4
Name: as-dict-rec
Version: 0.1.1
Summary: Reduce a complex Python structure to basic types
Project-URL: Homepage, https://devel.ringlet.net/devel/as-dict-rec/
Project-URL: Changes, https://devel.ringlet.net/devel/as-dict-rec/changes/
Project-URL: Issue Tracker, https://todo.sr.ht/~ppentchev/as-dict-rec
Project-URL: Source Code, https://git.sr.ht/~ppentchev/as-dict-rec
Author-email: Peter Pentchev <roam@ringlet.net>
License-Expression: BSD-2-Clause
License-File: LICENSES/BSD-2-Clause.txt
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown

<!--
SPDX-FileCopyrightText: Peter Pentchev <roam@ringlet.net>
SPDX-License-Identifier: BSD-2-Clause
-->

# Reduce a complex Python structure to basic types

\[[Home][ringlet-home] | [sourcehut][sourcehut] | [PyPI][pypi] | [ReadTheDocs][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][pep508] syntax:

    as-dict-rec >= 0.1.10, < 0.2

[pep508]: https://peps.python.org/pep-0508/ "PEP 508 – Dependency specification for Python Software Packages"

## Basic usage

Convert a structure to a JSON representation:

``` python
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:

``` python
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][roam].
It is developed in [a sourcehut repository][sourcehut].
This documentation is hosted at [Ringlet][ringlet-home] with a copy at
[ReadTheDocs][readthedocs].

[roam]: mailto:roam@ringlet.net "Peter Pentchev"
[pypi]: https://pypi.org/project/as-dict-rec/ "The as-dict-rec Python Package Index page"
[readthedocs]: https://as-dict-rec.readthedocs.io/ "The as-dict-rec ReadTheDocs page"
[ringlet-home]: https://devel.ringlet.net/devel/as-dict-rec/ "The Ringlet as-dict-rec homepage"
[sourcehut]: https://git.sr.ht/~ppentchev/as-dict-rec "The as-dict-rec sourcehut repository"
