{"id":7134,"library":"databind-core","title":"Databind Core","description":"Databind Core is a Python library, currently at version 4.5.4, designed for de-serializing Python dataclasses, drawing inspiration from Java's Jackson Databind. It is compatible with Python 3.8 and newer. This package is now deprecated; users are advised to migrate to the `databind` package, which consolidates `databind-core` and `databind-json`.","status":"deprecated","version":"4.5.4","language":"en","source_language":"en","source_url":"https://github.com/NiklasRosenstein/python-databind","tags":["serialization","deserialization","dataclasses","json","data binding","deprecated"],"install":[{"cmd":"pip install databind-core","lang":"bash","label":"Install databind-core (deprecated)"},{"cmd":"pip install databind","lang":"bash","label":"Install databind (recommended successor)"}],"dependencies":[{"reason":"Requires Python 3.8 or newer for core functionality.","package":"python","optional":false}],"imports":[{"note":"The `load` and `dump` functions for JSON de/serialization are now part of the `databind.json` module within the `databind` package. `databind-core` no longer directly exposes these.","wrong":"from databind.core.json import load, dump","symbol":"load, dump","correct":"from databind.json import load, dump"},{"note":"`dataclass` is a standard library feature, essential for defining data structures that `databind` processes.","symbol":"dataclass","correct":"from dataclasses import dataclass"}],"quickstart":{"code":"from dataclasses import dataclass\nfrom databind.json import dump, load\nimport os\n\n# Note: This quickstart uses the 'databind' package (the recommended successor)\n# as 'databind-core' is deprecated and its JSON functionality has moved.\n\n@dataclass\nclass Server:\n    host: str\n    port: int\n\n@dataclass\nclass Config:\n    server: Server\n\n# Example payload\ndict_payload = {\"server\": {\"host\": \"localhost\", \"port\": 8080}}\n\n# Load data into a dataclass instance\nloaded_config = load(dict_payload, Config)\nprint(f\"Loaded Config: {loaded_config}\")\n\n# Dump a dataclass instance back to a dictionary\ndumped_payload = dump(loaded_config, Config)\nprint(f\"Dumped Payload: {dumped_payload}\")\n\nassert loaded_config == Config(server=Server(host=\"localhost\", port=8080))\nassert dumped_payload == dict_payload\n","lang":"python","description":"This quickstart demonstrates basic JSON de/serialization using the `databind` package, which is the recommended successor to `databind-core`. It shows how to define dataclasses and use `load` and `dump` for conversion between dictionaries and dataclass instances."},"warnings":[{"fix":"Uninstall `databind-core` (`pip uninstall databind-core`) and install `databind` (`pip install databind`). Update import paths accordingly (e.g., `from databind.json import load, dump`).","message":"The `databind-core` package is officially deprecated. All new development and maintenance will focus on the unified `databind` package. Users should migrate to `databind` for continued support and new features.","severity":"deprecated","affected_versions":">=4.5.0"},{"fix":"Upgrade your Python environment to 3.8 or newer, or pin `databind-core` to a version older than 4.5.0 if Python 3.6/3.7 support is strictly required (not recommended due to deprecation).","message":"Version 4.5.0 of `databind-core` dropped support for Python 3.6 and 3.7. Attempting to use this version on unsupported Python versions will lead to installation or runtime errors.","severity":"breaking","affected_versions":">=4.5.0"},{"fix":"Upgrade to `databind-core` version 4.5.4 or later, or migrate to the `databind` package.","message":"Prior to version 4.5.4, `Union` settings inherited via MRO could cause `RecursionError` during serialization/deserialization, especially with complex inheritance hierarchies involving `Union` types.","severity":"gotcha","affected_versions":"<4.5.4"},{"fix":"Upgrade to `databind-core` version 4.5.3 or later, or migrate to the `databind` package.","message":"Prior to version 4.5.3, dataclasses inheriting from uninstantiated `Generic` types might not have all their fields correctly serialized, leading to incomplete output.","severity":"gotcha","affected_versions":"<4.5.3"},{"fix":"Upgrade to `databind-core` version 4.5.3 or later, or migrate to the `databind` package.","message":"Before version 4.5.3, `Union` types containing `typing.Literal` were unable to correctly de/serialize, resulting in errors when processing data that matched these patterns.","severity":"gotcha","affected_versions":"<4.5.3"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install the `databind` package (`pip install databind`) and ensure your import statement is `from databind.json import load, dump`.","cause":"Attempting to import `databind.json` after `databind-core`'s JSON functionality was moved into the new, consolidated `databind` package.","error":"ModuleNotFoundError: No module named 'databind.json'"},{"fix":"Upgrade `databind-core` to version 4.5.4 or higher, or preferably, migrate to the `databind` package.","cause":"This error often occurs in older `databind-core` versions (prior to 4.5.4) due to a bug where `Union` settings inherited through the Method Resolution Order (MRO) would cause an infinite recursion loop during de/serialization.","error":"RecursionError: maximum recursion depth exceeded while calling a Python object"},{"fix":"Upgrade `databind-core` to version 4.5.3 or higher, or migrate to the `databind` package.","cause":"When deserializing into a dataclass that inherits from an uninstantiated `Generic` type, older `databind-core` versions (prior to 4.5.3) could fail to correctly resolve and serialize all fields.","error":"TypeError: Cannot deserialize into a generic type without type arguments."}]}