Skip to main content

Databind is a library inspired by jackson-databind to de-/serialize Python dataclasses. The `databind` package will install the full suite of databind packages. Compatible with Python 3.8 and newer.

Project description

databind

Python versions Documentation

The databind package provides a (de)serialization framework that understands most native Python types as well as dataclasses, as well as an implementation for serialize to/from JSON-like nested data structures.

Databind is intended mostly for flexible and easy to use configuration loading. It does not try achieve high-performance; you should look towards e.g. mashumaro for this usecase.

Example

@dataclass
class Server:
    host: str
    port: int

@dataclass
class Config:
    server: Server

from databind.json import dump, load

dict_payload = {"server": {"host": "localhost", "port": 8080}}
loaded = Config(server=Server(host="localhost", port=8080))

assert load(dict_payload, Config) == loaded
assert dump(loaded, Config) == dict_payload

Features ✨

  • Support for a plethora of builtin types, including Enum, Decimal, UUID, Path, datetime, date, time, timedelta
  • Support for multiple union serialization modes (nested, flat, keyed, typing.Literal)
  • Support for generic types, e.g. load([{"name": "Jane Doe"}], list[Person])
  • Support for new-style type hints in older Python versions when using forward refererences (strings or __future__.annotations) thanks to typeapi
  • Support for customized serialization and deserialization of types
  • Support for flattening fields of a nested dataclass or collecting remaining fields in a dict
  • Full runtime type checking during serialization
  • Use "settings" to customize serialization behaviour
    • As global settings per load()/dump() call: load(..., settings=[ExtraKeys(True)])
    • As class-level settings using a decorator: @Union(style=Union.FLAT) or @ExtraKeys(True)
    • As type-hint level settings using typing.Annotated (or typing_extensions.Annotated): full_name: Annotated[str, Alias("fullName")] or FullNameField = Annotated[str, Alias("fullName")]

Notable release notes

4.5.0

  • Merged databind.core and databind.json packages into databind. The old PyPI packages will remain as proxies until the next minor version.
  • Dropped support for Python 3.6 and 3.7.

Copyright © 2022 – Niklas Rosenstein

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

databind-4.5.3.tar.gz (42.6 kB view details)

Uploaded Source

Built Distribution

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

databind-4.5.3-py3-none-any.whl (51.8 kB view details)

Uploaded Python 3

File details

Details for the file databind-4.5.3.tar.gz.

File metadata

  • Download URL: databind-4.5.3.tar.gz
  • Upload date:
  • Size: 42.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for databind-4.5.3.tar.gz
Algorithm Hash digest
SHA256 24c84bce51ac87348563b2f9754b5ef61b4a0c61be21b961a0424258a4150802
MD5 4c423b29fc15c65c98cfbad678172c4e
BLAKE2b-256 a221a6c0a82f73b375b51d9b6f5bc673874d01a17bc0df2ccb216ac00760165f

See more details on using hashes here.

Provenance

The following attestation bundles were made for databind-4.5.3.tar.gz:

Publisher: python.yaml on NiklasRosenstein/python-databind

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file databind-4.5.3-py3-none-any.whl.

File metadata

  • Download URL: databind-4.5.3-py3-none-any.whl
  • Upload date:
  • Size: 51.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for databind-4.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 54ed3e82ee4e5b789ad6670077e101f79449d9b224bee19a99ef0ad12f449862
MD5 cde75cca39ca7e6a6a4ed6cfd753b82e
BLAKE2b-256 7604e6484f2cd9f53d5fa485792aae25bc9845d0684c63b97783624ce17e76d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for databind-4.5.3-py3-none-any.whl:

Publisher: python.yaml on NiklasRosenstein/python-databind

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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