Install & Compatibility
Where this runs
tested against v4.5.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.940 runs
installs and imports cleanly · install 0.0s · import 0.000s · 68.6MB
glibcpy 3.10–3.940 runs
installs and imports cleanly · install 2.3s · import 0.000s · 20MB
43MB installed
● package 43MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
dumps
✓ from databind_json import dumps
loads
✓ from databind_json import loads
Demonstrates basic serialization and deserialization of dataclasses, including handling of `Optional` fields and nested dataclasses, using the `dumps` and `loads` functions from `databind_json`.
from dataclasses import dataclass
from typing import Optional, Union
from databind_json import dumps, loads
@dataclass
class Address:
street: str
city: str
@dataclass
class User:
id: int
name: str
email: Optional[str] = None
address: Optional[Address] = None
# Serialize a User object
user = User(id=123, name="Alice Smith", email="alice@example.com", address=Address(street="123 Main St", city="Anytown"))
json_payload = dumps(user)
print("Serialized JSON:", json_payload)
# Deserialize a JSON string back into a User object
json_string_to_load = '{"id": 456, "name": "Bob Johnson", "email": null, "address": {"street": "456 Oak Ave", "city": "Otherville"}}'
deserialized_user = loads(json_string_to_load, User)
print("Deserialized User:", deserialized_user)
# Example with an optional field not present in JSON (deserializes to None)
json_no_address = '{"id": 789, "name": "Charlie Brown"}'
user_no_address = loads(json_no_address, User)
print("User with no address in JSON:", user_no_address)
Debug
Known issues
breakingThe `databind-json` package is officially deprecated and is no longer the recommended library for JSON serialization of dataclasses. Its functionality has been fully integrated into the `databind` library under the `databind.json` module.fixMigrate to the `databind` package. Install using `pip install databind` and update your import statements from `from databind_json import ...` to `from databind.json import ...`.
affects: All versions
gotchaIncorrect handling or complex definitions of `typing.Union` or `typing.Optional` types within dataclass fields can lead to unexpected serialization failures or `RecursionError`. This is especially relevant when `Union` types include `typing.Literal` values or when Union settings are inherited via MRO.fixEnsure `Union` types are precisely defined (e.g., more specific types before less specific ones). For `Optional[T]`, use `Union[T, None]`. Upgrade to `databind-json` 4.5.4 (or `databind` 4.5.4) to benefit from recent fixes related to `RecursionError` and `Union` with `Literal` types. Refer to the `databind` documentation for best practices on complex type hints.
affects: <4.5.4 (for RecursionError), <4.5.3 (for Union with Literal)
gotchaDataclasses inheriting from uninstantiated `typing.Generic` types may not have all their fields correctly discovered and serialized. Similarly, complex inheritance structures involving `__databind_settings__` on subclasses can introduce subtle bugs or unexpected behavior.fixUpgrade to `databind-json` 4.5.4 (or `databind` 4.5.4). Carefully review dataclass inheritance patterns involving generics, ensuring they are correctly instantiated or that field inference is unambiguous. Consult the `databind` documentation on class settings and inheritance for detailed guidance.
affects: <4.5.3 (for Generic inheritance), <4.5.4 (for __databind_settings__ issues)
Upgrade
Version history
4.5.5latest on PyPI · released May 22, 2026
Audit
Dependencies
No dependency data recorded yet.