Name | databind JSON |
Version |
4.5.2
JSON |
| download |
home_page | None |
Summary | 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. |
upload_time | 2024-05-31 15:29:07 |
maintainer | None |
docs_url | None |
author | Niklas Rosenstein |
requires_python | <4.0.0,>=3.8.0 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<p align="center"><img src="https://i.imgur.com/KkWFne2.png" width="256px"></p>
<h1 align="center">databind</h1>
<p align="center">
<img src="https://img.shields.io/pypi/pyversions/databind?style=flat" alt="Python versions">
<a href="https://pypi.org/project/databind/"><img src="https://img.shields.io/pypi/v/databind?flat"></a>
<a href="https://NiklasRosenstein.github.io/python-databind/"><img src="https://img.shields.io/badge/Documentation-blue?style=flat&logo=gitbook&logoColor=white" alt="Documentation"></a>
</p>
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](https://pypi.org/project/mashumaro/) for this usecase.
### Example
```python
@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 ✨
[typeapi]: https://github.com/NiklasRosenstein/python-typeapi
* 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][]
* [PEP 604 - Allow writing union types as X | Y](https://www.python.org/dev/peps/pep-0604/)
* [PEP585 - Type Hinting Generics in Standard Collections](https://www.python.org/dev/peps/pep-0585/))
* 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.
---
<p align="center">Copyright © 2022 – Niklas Rosenstein</p>
Raw data
{
"_id": null,
"home_page": null,
"name": "databind",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0.0,>=3.8.0",
"maintainer_email": null,
"keywords": null,
"author": "Niklas Rosenstein",
"author_email": "rosensteinniklas@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/0c/b8/a6beffa3dd3d7898003d32b3ff5dc0be422c54efed5e0e3f85e92c65c2b2/databind-4.5.2.tar.gz",
"platform": null,
"description": "<p align=\"center\"><img src=\"https://i.imgur.com/KkWFne2.png\" width=\"256px\"></p>\n\n<h1 align=\"center\">databind</h1>\n\n<p align=\"center\">\n <img src=\"https://img.shields.io/pypi/pyversions/databind?style=flat\" alt=\"Python versions\">\n <a href=\"https://pypi.org/project/databind/\"><img src=\"https://img.shields.io/pypi/v/databind?flat\"></a>\n <a href=\"https://NiklasRosenstein.github.io/python-databind/\"><img src=\"https://img.shields.io/badge/Documentation-blue?style=flat&logo=gitbook&logoColor=white\" alt=\"Documentation\"></a>\n</p>\n\nThe `databind` package provides a (de)serialization framework that understands most native Python types as well as\ndataclasses, as well as an implementation for serialize to/from JSON-like nested data structures.\n\nDatabind is intended mostly for flexible and easy to use configuration loading. It does __not__ try achieve\nhigh-performance; you should look towards e.g. [mashumaro](https://pypi.org/project/mashumaro/) for this usecase.\n\n### Example\n\n```python\n@dataclass\nclass Server:\n host: str\n port: int\n\n@dataclass\nclass Config:\n server: Server\n\nfrom databind.json import dump, load\n\ndict_payload = {\"server\": {\"host\": \"localhost\", \"port\": 8080}}\nloaded = Config(server=Server(host=\"localhost\", port=8080))\n\nassert load(dict_payload, Config) == loaded\nassert dump(loaded, Config) == dict_payload\n```\n\n## Features \u2728\n\n [typeapi]: https://github.com/NiklasRosenstein/python-typeapi\n\n* Support for a plethora of builtin types, including `Enum`, `Decimal`, `UUID`, `Path`, `datetime`, `date`,\n `time`, `timedelta`\n* Support for multiple union serialization modes (nested, flat, keyed, `typing.Literal`)\n* Support for generic types, e.g. `load([{\"name\": \"Jane Doe\"}], list[Person])`\n* Support for new-style type hints in older Python versions when using forward refererences (strings or\n `__future__.annotations`) thanks to [typeapi][]\n * [PEP 604 - Allow writing union types as X | Y](https://www.python.org/dev/peps/pep-0604/)\n * [PEP585 - Type Hinting Generics in Standard Collections](https://www.python.org/dev/peps/pep-0585/))\n* Support for customized serialization and deserialization of types\n* Support for flattening fields of a nested dataclass or collecting remaining fields in a `dict`\n* Full runtime type checking during serialization\n* Use \"settings\" to customize serialization behaviour\n * As global settings per `load()`/`dump()` call: `load(..., settings=[ExtraKeys(True)])`\n * As class-level settings using a decorator: `@Union(style=Union.FLAT)` or `@ExtraKeys(True)`\n * As type-hint level settings using `typing.Annotated` (or `typing_extensions.Annotated`):\n `full_name: Annotated[str, Alias(\"fullName\")]` or `FullNameField = Annotated[str, Alias(\"fullName\")]`\n\n## Notable release notes\n\n### 4.5.0\n\n* Merged `databind.core` and `databind.json` packages into `databind`. The old PyPI packages will remain as proxies\n until the next minor version.\n* Dropped support for Python 3.6 and 3.7.\n\n---\n\n<p align=\"center\">Copyright © 2022 – Niklas Rosenstein</p>\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "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.",
"version": "4.5.2",
"project_urls": {
"Bug Tracker": "https://github.com/NiklasRosenstein/python-databind/issues",
"Documentation": "https://niklasrosenstein.github.io/python-databind/",
"Repository": "https://github.com/NiklasRosenstein/python-databind"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0b5b39577d7629da11765786f45a37dccdf7f420038f6040325fe1ca40f52a93",
"md5": "48d9fab98e1e3f250bd7113f862fe904",
"sha256": "b9c3a03c0414aa4567f095d7218ac904bd2b267b58e3763dac28e83d64b69770"
},
"downloads": -1,
"filename": "databind-4.5.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "48d9fab98e1e3f250bd7113f862fe904",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0.0,>=3.8.0",
"size": 49283,
"upload_time": "2024-05-31T15:29:00",
"upload_time_iso_8601": "2024-05-31T15:29:00.026699Z",
"url": "https://files.pythonhosted.org/packages/0b/5b/39577d7629da11765786f45a37dccdf7f420038f6040325fe1ca40f52a93/databind-4.5.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0cb8a6beffa3dd3d7898003d32b3ff5dc0be422c54efed5e0e3f85e92c65c2b2",
"md5": "9850327a73c2d3aa7988ab5d2666386e",
"sha256": "0a8aa0ff130a0306581c559388f5ef65e0fae7ef4b86412eacb1f4a0420006c4"
},
"downloads": -1,
"filename": "databind-4.5.2.tar.gz",
"has_sig": false,
"md5_digest": "9850327a73c2d3aa7988ab5d2666386e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0.0,>=3.8.0",
"size": 43001,
"upload_time": "2024-05-31T15:29:07",
"upload_time_iso_8601": "2024-05-31T15:29:07.728625Z",
"url": "https://files.pythonhosted.org/packages/0c/b8/a6beffa3dd3d7898003d32b3ff5dc0be422c54efed5e0e3f85e92c65c2b2/databind-4.5.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-31 15:29:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "NiklasRosenstein",
"github_project": "python-databind",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "databind"
}