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.4.tar.gz (43.2 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.4-py3-none-any.whl (52.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: databind-4.5.4.tar.gz
  • Upload date:
  • Size: 43.2 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.4.tar.gz
Algorithm Hash digest
SHA256 342e170a219b1661e5c1b20778b532aecfa67e46560ba75beb7e2c6faa2150b5
MD5 0d20030eab4b8abc95d2b05b06fb9949
BLAKE2b-256 719e835a5211eeb7228a0e3870d54def48dd7951dbd951f51b30900020a5f9fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for databind-4.5.4.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.4-py3-none-any.whl.

File metadata

  • Download URL: databind-4.5.4-py3-none-any.whl
  • Upload date:
  • Size: 52.4 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 78467f874a3e80bcd1d3de349167587a0d369831bc64c03798520be86074f96e
MD5 8d61cfa7af8f2c1943a9fe0c2a3a2851
BLAKE2b-256 e2db3b8eb860b5baef89b72c7aadcc5072e1648ca0c98d6ba4b9e4eabbdc2cf5

See more details on using hashes here.

Provenance

The following attestation bundles were made for databind-4.5.4-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