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.5.tar.gz (43.5 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.5-py3-none-any.whl (52.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for databind-4.5.5.tar.gz
Algorithm Hash digest
SHA256 594c1b13b754c30f95faf85bba4a4cc5768243a6a9818a87a66a616d8848a54b
MD5 8a3e34bddf2fc2451641cd0788a45b0e
BLAKE2b-256 164ac4bb226245299d22ef9ccde502cb658d318850e4fa7f4b0a416d3aa5324a

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for databind-4.5.5-py3-none-any.whl
Algorithm Hash digest
SHA256 78b5d740dcb2f457fbb8f09d989ce8c0917b44b60922751df61be0d0fe0660aa
MD5 47dd5b856d4919b61c1a6266b1b153a0
BLAKE2b-256 838991ccb7aa370b2b0bc85e45de267c4e3e5f3f7752883d462ea6c11cc92466

See more details on using hashes here.

Provenance

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