|
1 |
| -# databind.json |
2 | 1 |
|
3 |
| -The `databind.json` package implements the de-/serialization to or from JSON payloads using |
4 |
| -the `databind.core` framework. |
5 |
| - |
6 |
| -Check out the [Documentation][0] for examples. |
7 |
| - |
8 |
| -[0]: https://niklasrosenstein.github.io/python-databind/ |
9 |
| - |
10 |
| -## Built-in converters |
11 |
| - |
12 |
| -The following tables shows which types can be deserialized from / serialize to Python types with the native |
13 |
| -converters provided by the `databind.json` module: |
14 |
| - |
15 |
| -| Converter name | Types | Description | |
16 |
| -| -------------- | ----- | ----------- | |
17 |
| -| `AnyConverter` | `typing.Any` | Accept any value (useful for arbitrary JSON). | |
18 |
| -| `CollectionConverter` | `typing.Collection[T]`, excl. `str`, `bytes`, `bytearray`, `memoryview` and `typing.Mapping[K, V]` | Converts between native Python collections and JSON arrays. | |
19 |
| -| `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). | |
20 |
| -| `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. | |
21 |
| -| `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). | |
22 |
| -| `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`). | |
23 |
| -| `OptionalConverter` | `typing.Optional[T]` | Handles optional fields in a schema. | |
24 |
| -| `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. | |
25 |
| -| `SchemaConverter` | `dataclasses.dataclass`, `typing.TypedDict` | Converts between Python dataclasses or typed dictionary and JSON objects. | |
26 |
| -| `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. | |
27 |
| -| `LiteralConverter` | `typing.Literal[...]` | Accepts or rejects a value based on whether it matches one of the values in the literal type hint. | |
28 |
| - |
29 |
| - |
30 |
| -The following converters are provided for convenience: |
31 |
| - |
32 |
| -| Converter name | Types | Description | |
33 |
| -| -------------- | ----- | ----------- | |
34 |
| -| `StringifyConverter` | n/a | A helper that allows to easily create de/serializers from a "to string" and "from string" function. | |
35 |
| - |
36 |
| -The following additional types are natively supported by `databind.json` using `StringifyConverter`: |
37 |
| - |
38 |
| -| Types | Description | |
39 |
| -| ----- | ----------- | |
40 |
| -| `uuid.UUID` | Convert between strings and UUIDs. | |
41 |
| -| `pathlib.Path` | Convert between strings and paths. | |
42 |
| -| `pathlib.PurePath` | Convert between strings and paths. | |
43 |
| -| `nr.date.duration` | Deserialize from ISO 8601 duration strings or the object form, serialize to ISO 8601 strings. | |
44 |
| - |
45 |
| ---- |
46 |
| - |
47 |
| -<p align="center">Copyright © 2020 – Niklas Rosenstein</p> |
| 2 | +Deprecated since v4.5.0. This is a proxy for depending on [`databind`](https://pypi.org/project/databind/). Do not |
| 3 | +depend on this package directly anymore. |
0 commit comments