Name | databind-json2 JSON |
Version |
4.2.2
JSON |
| download |
home_page | |
Summary | De-/serialize Python dataclasses to or from JSON payloads. Compatible with Python 3.7 and newer. |
upload_time | 2023-01-26 13:11:29 |
maintainer | |
docs_url | None |
author | Niklas Rosenstein |
requires_python | >=3.6.3,<4.0.0 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# databind.json
The `databind.json` package implements the de-/serialization to or from JSON payloads using
the `databind.core` framework.
Check out the [Documentation][0] for examples.
[0]: https://niklasrosenstein.github.io/python-databind/
## Built-in converters
The following tables shows which types can be deserialized from / serialize to Python types with the native
converters provided by the `databind.json` module:
| Converter name | Types | Description |
| -------------- | ----- | ----------- |
| `AnyConverter` | `typing.Any` | Accept any value (useful for arbitrary JSON). |
| `CollectionConverter` | `typing.Collection[T]`, excl. `str`, `bytes`, `bytearray`, `memoryview` and `typing.Mapping[K, V]` | Converts between native Python collections and JSON arrays. |
| `DatetimeConverter` | `datetime.date`, `datetime.datetime`, `datetime.time` | Converts between strings and date/time formats, using ISO 8601 time format by default (can be changed with the `databind.core.settings.DateFormat` setting). |
| `DecimalConverter` | `decimal.Decimal` | Converts between strings (and ints/floats if strict mode is off, strict mode is on by default) and decimals. The precision can be controlled with the `databind.core.settings.Precision` setting. |
| `EnumConverter` | `enum.Enum`, `enum.IntEnum` | Convert between strings and Python enumerations. The serialized form of `IntEnum` is the integer value, whereas the serialized form of `Enum` is a string (name of the enumeration value). |
| `MappingConverter` | `typing.Mapping[K, V]` | Converts between Python dicts and JSON objects. (While in theory `K` can be any type, for JSON `K` always needs to be `str`). |
| `OptionalConverter` | `typing.Optional[T]` | Handles optional fields in a schema. |
| `PlainDatatypeConverter` | `bytes`, `str`, `int`, `float`, `bool` | Converts between plain datatypes. In non-strict mode (off by default), numeric types will also accept strings as input for the deserialization. |
| `SchemaConverter` | `dataclasses.dataclass`, `typing.TypedDict` | Converts between Python dataclasses or typed dictionary and JSON objects. |
| `UnionConverter` | `typing.Union[...]` | Handles union types. Unions in JSON can be expressed in a multitide of ways, e.g. using a discriminator key and flat, keyed or nested structure or "best match". Check out the examples section of the documentation for more information. |
| `LiteralConverter` | `typing.Literal[...]` | Accepts or rejects a value based on whether it matches one of the values in the literal type hint. |
The following converters are provided for convenience:
| Converter name | Types | Description |
| -------------- | ----- | ----------- |
| `StringifyConverter` | n/a | A helper that allows to easily create de/serializers from a "to string" and "from string" function. |
The following additional types are natively supported by `databind.json` using `StringifyConverter`:
| Types | Description |
| ----- | ----------- |
| `uuid.UUID` | Convert between strings and UUIDs. |
| `pathlib.Path` | Convert between strings and paths. |
| `pathlib.PurePath` | Convert between strings and paths. |
| `nr.date.duration` | Deserialize from ISO 8601 duration strings or the object form, serialize to ISO 8601 strings. |
---
<p align="center">Copyright © 2020 – Niklas Rosenstein</p>
Raw data
{
"_id": null,
"home_page": "",
"name": "databind-json2",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6.3,<4.0.0",
"maintainer_email": "",
"keywords": "",
"author": "Niklas Rosenstein",
"author_email": "rosensteinniklas@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/9f/2f/713f1944abf0fceb1d9293d4ccb8ed7e526a3d211aff70e4a6e6d3d4d12a/databind_json2-4.2.2.tar.gz",
"platform": null,
"description": "# databind.json\n\nThe `databind.json` package implements the de-/serialization to or from JSON payloads using\nthe `databind.core` framework.\n\nCheck out the [Documentation][0] for examples.\n\n[0]: https://niklasrosenstein.github.io/python-databind/\n\n## Built-in converters\n\nThe following tables shows which types can be deserialized from / serialize to Python types with the native\nconverters provided by the `databind.json` module:\n\n| Converter name | Types | Description |\n| -------------- | ----- | ----------- |\n| `AnyConverter` | `typing.Any` | Accept any value (useful for arbitrary JSON). |\n| `CollectionConverter` | `typing.Collection[T]`, excl. `str`, `bytes`, `bytearray`, `memoryview` and `typing.Mapping[K, V]` | Converts between native Python collections and JSON arrays. |\n| `DatetimeConverter` | `datetime.date`, `datetime.datetime`, `datetime.time` | Converts between strings and date/time formats, using ISO 8601 time format by default (can be changed with the `databind.core.settings.DateFormat` setting). |\n| `DecimalConverter` | `decimal.Decimal` | Converts between strings (and ints/floats if strict mode is off, strict mode is on by default) and decimals. The precision can be controlled with the `databind.core.settings.Precision` setting. |\n| `EnumConverter` | `enum.Enum`, `enum.IntEnum` | Convert between strings and Python enumerations. The serialized form of `IntEnum` is the integer value, whereas the serialized form of `Enum` is a string (name of the enumeration value). |\n| `MappingConverter` | `typing.Mapping[K, V]` | Converts between Python dicts and JSON objects. (While in theory `K` can be any type, for JSON `K` always needs to be `str`). |\n| `OptionalConverter` | `typing.Optional[T]` | Handles optional fields in a schema. |\n| `PlainDatatypeConverter` | `bytes`, `str`, `int`, `float`, `bool` | Converts between plain datatypes. In non-strict mode (off by default), numeric types will also accept strings as input for the deserialization. |\n| `SchemaConverter` | `dataclasses.dataclass`, `typing.TypedDict` | Converts between Python dataclasses or typed dictionary and JSON objects. |\n| `UnionConverter` | `typing.Union[...]` | Handles union types. Unions in JSON can be expressed in a multitide of ways, e.g. using a discriminator key and flat, keyed or nested structure or \"best match\". Check out the examples section of the documentation for more information. |\n| `LiteralConverter` | `typing.Literal[...]` | Accepts or rejects a value based on whether it matches one of the values in the literal type hint. |\n\n\nThe following converters are provided for convenience:\n\n| Converter name | Types | Description |\n| -------------- | ----- | ----------- |\n| `StringifyConverter` | n/a | A helper that allows to easily create de/serializers from a \"to string\" and \"from string\" function. |\n\nThe following additional types are natively supported by `databind.json` using `StringifyConverter`:\n\n| Types | Description |\n| ----- | ----------- |\n| `uuid.UUID` | Convert between strings and UUIDs. |\n| `pathlib.Path` | Convert between strings and paths. |\n| `pathlib.PurePath` | Convert between strings and paths. |\n| `nr.date.duration` | Deserialize from ISO 8601 duration strings or the object form, serialize to ISO 8601 strings. |\n\n---\n\n<p align=\"center\">Copyright © 2020 – Niklas Rosenstein</p>\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "De-/serialize Python dataclasses to or from JSON payloads. Compatible with Python 3.7 and newer.",
"version": "4.2.2",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bb73b28ee8af93ada67fe9a584f661d80f9609b1e2eed5f5c8149f5587e97b50",
"md5": "211d0c4de2e93aac31ec2c366b881404",
"sha256": "2c01112bded802e583045600cb16a184dec2f25817fffc7080e5b53bd10109e0"
},
"downloads": -1,
"filename": "databind_json2-4.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "211d0c4de2e93aac31ec2c366b881404",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6.3,<4.0.0",
"size": 12692,
"upload_time": "2023-01-26T13:11:27",
"upload_time_iso_8601": "2023-01-26T13:11:27.585662Z",
"url": "https://files.pythonhosted.org/packages/bb/73/b28ee8af93ada67fe9a584f661d80f9609b1e2eed5f5c8149f5587e97b50/databind_json2-4.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9f2f713f1944abf0fceb1d9293d4ccb8ed7e526a3d211aff70e4a6e6d3d4d12a",
"md5": "e6838096dcc98a42bb6058ddcaf35a8b",
"sha256": "0104e5bf22b4ed8bb4154d6edc34aeb8ff2cd0f49b2a0bdb064dc3c281de11a1"
},
"downloads": -1,
"filename": "databind_json2-4.2.2.tar.gz",
"has_sig": false,
"md5_digest": "e6838096dcc98a42bb6058ddcaf35a8b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6.3,<4.0.0",
"size": 13116,
"upload_time": "2023-01-26T13:11:29",
"upload_time_iso_8601": "2023-01-26T13:11:29.367093Z",
"url": "https://files.pythonhosted.org/packages/9f/2f/713f1944abf0fceb1d9293d4ccb8ed7e526a3d211aff70e4a6e6d3d4d12a/databind_json2-4.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-26 13:11:29",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "databind-json2"
}