| 1 |
Metadata-Version: 2.1 |
| 2 |
Name: serializable |
| 3 |
Version: 0.4.1 |
| 4 |
Summary: Base class with serialization helpers for user-defined Python objects |
| 5 |
Home-page: https://github.com/iskandr/serializable |
| 6 |
Author: Alex Rubinsteyn |
| 7 |
Author-email: [email protected] |
| 8 |
License: http://www.apache.org/licenses/LICENSE-2.0.html |
| 9 |
Classifier: Development Status :: 3 - Alpha |
| 10 |
Classifier: Environment :: Console |
| 11 |
Classifier: Operating System :: OS Independent |
| 12 |
Classifier: License :: OSI Approved :: Apache Software License |
| 13 |
Classifier: Programming Language :: Python |
| 14 |
Description-Content-Type: text/markdown |
| 15 |
License-File: LICENSE |
| 16 |
Requires-Dist: typechecks>=0.0.2 |
| 17 |
Requires-Dist: simplejson |
| 18 |
|
| 19 |
[](https://github.com/openvax/serializable/actions/workflows/tests.yml) |
| 20 |
<a href="https://pypi.python.org/pypi/serializable/"> |
| 21 |
<img src="https://img.shields.io/pypi/v/serializable.svg?maxAge=1000" alt="PyPI" /> |
| 22 |
</a> |
| 23 |
[](https://pypistats.org/packages/serializable) |
| 24 |
|
| 25 |
# serializable |
| 26 |
|
| 27 |
Base class with serialization methods for user-defined Python objects |
| 28 |
|
| 29 |
## Usage |
| 30 |
|
| 31 |
Classes which inherit from `Serializable` are enabled with default implementations of |
| 32 |
`to_json`, `from_json`, `__reduce__` (for pickling), and other serialization |
| 33 |
helpers. |
| 34 |
|
| 35 |
A derived class must either: |
| 36 |
|
| 37 |
- have a member data matching the name of each argument to `__init__` |
| 38 |
- provide a user-defined `to_dict()` method which returns a dictionary whose keys match the arguments to `__init__` |
| 39 |
|
| 40 |
If you change the keyword arguments to a class which derives from `Serializable` but would like to be able to deserialize older JSON representations then you can define a class-level dictionary called `_KEYWORD_ALIASES` which maps old keywords to new names (or `None` if a keyword was removed). |
| 41 |
|
| 42 |
## Limitations |
| 43 |
|
| 44 |
- Serializable objects must inherit from `Serializable`, be tuples or namedtuples, be serializble primitive types such as dict, list, int, float, or str. |
| 45 |
|
| 46 |
- The serialized representation of objects relies on reserved keywords (such as `"__name__"`, and `"__class__"`), so dictionaries are expected to not contain any keys which begin with two underscores. |