py-serializable
Library for serializing and deserializing Python Objects to and from JSON and XML.
Description
# py-serializable [![shield_pypi-version]][link_pypi] [![shield_conda-forge-version]][link_conda-forge] [![shield_rtfd]][link_rtfd] [![shield_gh-workflow-test]][link_gh-workflow-test] [![shield_license]][license_file] [![shield_twitter-follow]][link_twitter] ---- This Pythonic library provides a framework for serializing/deserializing Python classes to and from JSON and XML. It relies upon the use of [Python Properties](https://docs.python.org/3/library/functions.html?highlight=property#property) in your Python classes. Read the full [documentation][link_rtfd] for more details. ## Installation Install this from [PyPi.org][link_pypi] using your preferred Python package manager. Example using `pip`: ```shell pip install py-serializable ``` Example using `poetry`: ```shell poetry add py-serializable ``` ## Usage See the full [documentation][link_rtfd] or our [unit tests][link_unit_tests] for usage and details. ## Python Support We endeavour to support all functionality for all [current actively supported Python versions](https://www.python.org/downloads/). However, some features may not be possible/present in older Python versions due to their lack of support. ## Contributing Feel free to open issues, bugreports or pull requests. See the [CONTRIBUTING][contributing_file] file for details. ## Copyright & License `py-serializable` is Copyright (c) Paul Horton 2022. All Rights Reserved. Permission to modify and redistribute is granted under the terms of the Apache 2.0 license. See the [LICENSE][license_file] file for the full license. [license_file]: https://github.com/madpah/serializable/blob/main/LICENSE [contributing_file]: https://github.com/madpah/serializable/blob/main/CONTRIBUTING.md [link_rtfd]: https://py-serializable.readthedocs.io/ [shield_gh-workflow-test]: https://img.shields.io/github/actions/workflow/status/madpah/serializable/python.yml?branch=main "build" [shield_rtfd]: https://img.shields.io/readthedocs/py-serializable?logo=readthedocs&logoColor=white [shield_pypi-version]: https://img.shields.io/pypi/v/py-serializable?logo=Python&logoColor=white&label=PyPI "PyPI" [shield_conda-forge-version]: https://img.shields.io/conda/vn/conda-forge/py-serializable?logo=anaconda&logoColor=white&label=conda-forge "conda-forge" [shield_license]: https://img.shields.io/github/license/madpah/serializable?logo=open%20source%20initiative&logoColor=white "license" [shield_twitter-follow]: https://img.shields.io/badge/Twitter-follow-blue?logo=Twitter&logoColor=white "twitter follow" [link_gh-workflow-test]: https://github.com/madpah/serializable/actions/workflows/python.yml?query=branch%3Amain [link_pypi]: https://pypi.org/project/py-serializable/ [link_conda-forge]: https://anaconda.org/conda-forge/py-serializable [link_twitter]: https://twitter.com/madpah [link_unit_tests]: https://github.com/madpah/serializable/blob/main/tests
Release History
| Version | Changes | Urgency | Date |
|---|---|---|---|
| 2.1.0 | Imported from PyPI (2.1.0) | Low | 4/21/2026 |
| v2.1.0 | # v2.1.0 (2025-07-21) ## Documentation * docs: fix typo in CONTRIBUTING guidelines ## Feature * feat: add support to ignore unknown properties/attributes/elements during deserialization (#178) ---- ## What's Changed * chore(deps-dev): update flake8 requirement from 7.1.1 to 7.1.2 by @dependabot[bot] in https://github.com/madpah/serializable/pull/165 * chore: GH workflow permissions by @jkowalleck in https://github.com/madpah/serializable/pull/169 * chore: bring pyupgrade t | Low | 7/21/2025 |
| v2.0.0 | # v2.0.0 (2025-02-09) ## Breaking * refactor!: rename python package `serializable` -> `py_serializable` (#155) The python package was renamed from `serializable` to `py_serializable`. Therefore, you need to adjust your imports. The following shows a quick way to adjust imports in the most efficient way. ### OLD imports ```py import serializable from serializable import ViewType, XmlArraySerializationType, XmlStringSerializationType from serializable.help | Low | 2/9/2025 |
| v2.0.0-alpha.1 | # v2.0.0-alpha.1 (2025-01-16) ## Breaking * refactor!: rename installable `serializable` -> `py_serializable` Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com> ([`39bfc1a`](https://github.com/madpah/serializable/commit/39bfc1a3f20efdb75be3b14e9bfa845dc1f62142)) ## Chore * chore: Create CODEOWNERS ([`960331a`](https://github.com/madpah/serializable/commit/960331ad5181b64afa140d1fd0d2d59b687d782b)) * chore(deps-dev): update mypy requirement from 1.13.0 to 1.14.1 (#154) Updates | Low | 1/16/2025 |
| v1.1.2 | # v1.1.2 (2024-10-01) ## Fix * fix: date/time deserialization with fractional seconds (#138) fix multiple where fractional seconds were not properly deserialized or deserialization caused unexpected crashes in py<3.11 --------- Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com> Co-authored-by: Jan Kowalleck <jan.kowalleck@gmail.com> ([`f4b1c27`](https://github.com/madpah/serializable/commit/f4b1c27110d1becc76771efffd8dc0a96d629cb5)) ## Refactor * refactor | Low | 10/1/2024 |
| v1.1.1 | # v1.1.1 (2024-09-16) ## Chore * chore(deps-dev): update mypy requirement from 1.11.1 to 1.11.2 (#133) Updates the requirements on [mypy](https://github.com/python/mypy) to permit the latest version. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.11.1...v1.11.2) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@git | Low | 9/16/2024 |
| v1.1.0 | # v1.1.0 (2024-07-08) ## Chore * chore(deps-dev): update autopep8 requirement from 2.3.0 to 2.3.1 (#118) Updates the requirements on [autopep8](https://github.com/hhatto/autopep8) to permit the latest version. - [Release notes](https://github.com/hhatto/autopep8/releases) - [Commits](https://github.com/hhatto/autopep8/compare/v2.3.0...v2.3.1) --- updated-dependencies: - dependency-name: autopep8 dependency-type: direct:development ... Signed-off-by: dependabot[bot] <sup | Low | 7/8/2024 |
| v1.0.3 | # v1.0.3 (2024-04-04) ## Chore * chore(deps-dev): update autopep8 requirement from 2.0.4 to 2.1.0 (#86) Updates the requirements on [autopep8](https://github.com/hhatto/autopep8) to permit the latest version. - [Release notes](https://github.com/hhatto/autopep8/releases) - [Commits](https://github.com/hhatto/autopep8/compare/v2.0.4...v2.1.0) --- updated-dependencies: - dependency-name: autopep8 dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@gi | Low | 4/4/2024 |
| v1.0.2 | # v1.0.2 (2024-03-01) Maintenance release. ## Build * build: use poetry v1.8.1 (#81) Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com> ([`46a8d9e`](https://github.com/madpah/serializable/commit/46a8d9e629ac502864a99acaa9418d1c5cd32388)) ## Chore * chore(deps-dev): update coverage requirement from 7.4.1 to 7.4.3 (#79) Updates the requirements on [coverage](https://github.com/nedbat/coveragepy) to permit the latest version. - [Release notes](https://github.com/nedb | Low | 3/1/2024 |
| v1.0.1 | # v1.0.1 (2024-02-13) ## Chore * chore(deps-dev): update coverage requirement from 7.4.0 to 7.4.1 (#69) Updates the requirements on [coverage](https://github.com/nedbat/coveragepy) to permit the latest version. - [Release notes](https://github.com/nedbat/coveragepy/releases) - [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst) - [Commits](https://github.com/nedbat/coveragepy/compare/7.4.0...7.4.1) --- updated-dependencies: - dependency-name: coverage dependen | Low | 2/13/2024 |
| v1.0.0 | # v1.0.0 (2024-01-22) **Release of first major version 🎉** ## BREAKING Changes * Dropped support for python <3.8 --------- ## What's Changed * chore: add `flake8-logging` by @jkowalleck in https://github.com/madpah/serializable/pull/61 * feat!: v1.0.0 by @jkowalleck in https://github.com/madpah/serializable/pull/55 **Full Changelog**: https://github.com/madpah/serializable/compare/v0.17.1...v1.0.0 | Low | 1/22/2024 |
| v1.0.0-rc.1 | # v1.0.0-rc.1 (2024-01-18) ## BREAKING changes * Dropped support for python <3.8 ---- Read the docs: https://py-serializable.readthedocs.io/en/dev-1.0.0/ ---- install a Release Candidate: ```shellSession $ pip install py-serializable==1.0.0rc1 $ poetry add py-serializable==1.0.0rc1 # you get the idea ... ``` ---- ## What's Changed * feat!: drop python<3.8 by @jkowalleck in https://github.com/madpah/serializable/pull/53 * chore: bump dev tools by @jkowalleck in | Low | 1/18/2024 |
| v0.17.1 | ### Fix * Log placeholder ([#60](https://github.com/madpah/serializable/issues/60)) ([`3cc6cad`](https://github.com/madpah/serializable/commit/3cc6cadad27a86b46ca576540f89a15f0f8fc1cd)) ### Documentation * Add "documentation" url to project meta ([`bf864d7`](https://github.com/madpah/serializable/commit/bf864d75d8a12426d4c71ae9ea1f533e730bd54e)) * Add "documentation" url to project meta ([`d3bcc42`](https://github.com/madpah/serializable/commit/d3bcc4258ab8cdf6c9e09b47985997cafdc19e9a) | Low | 1/7/2024 |
| v0.17.0 | ### Feature * Logger ([#47](https://github.com/madpah/serializable/issues/47)) ([`9269b0e`](https://github.com/madpah/serializable/commit/9269b0e681665abaef3f110925cd098b2438880f)) * see usage: https://py-serializable.readthedocs.io/en/latest/examples.html#logging-and-log-access ### Documentation * Modernixe read-the-docs ([`7ae6aad`](https://github.com/madpah/serializable/commit/7ae6aad3b5939508238d1502c116866ef79949cb)) * Homepage ([#48](https://github.com/madpah/serializable/iss | Low | 1/6/2024 |
| v0.16.0 | ### Feature * More controll over XML attribute serialization ([#34](https://github.com/madpah/serializable/issues/34)) ([`38f42d6`](https://github.com/madpah/serializable/commit/38f42d64e556a85206faa50459a9ce3e889bd3ae)) ---- ## What's Changed * feat: more controll over XML attribute serialization by @jkowalleck in https://github.com/madpah/serializable/pull/34 **Full Changelog**: https://github.com/madpah/serializable/compare/v0.15.0...v0.16.0 | Low | 11/29/2023 |
| v0.15.0 | ### Feature * Allow custom (de)normalization ([#32](https://github.com/madpah/serializable/issues/32)) ([`aeecd6b`](https://github.com/madpah/serializable/commit/aeecd6b2e8c4e8febc84ebfa24fe7ec96fd9cb10)) ----- ## What's Changed * feat: allow custom (de)normalization by @jkowalleck in https://github.com/madpah/serializable/pull/32 **Full Changelog**: https://github.com/madpah/serializable/compare/v0.14.1...v0.15.0 | Low | 10/10/2023 |
| v0.14.1 | ### Fix * JSON deserialize `Decimal` ([#31](https://github.com/madpah/serializable/issues/31)) ([`b6dc66a`](https://github.com/madpah/serializable/commit/b6dc66acfb7fdc82b3dd18caf4ad79ec0e87eef0)) ---- ## What's Changed * fix: JSON deserialize `Decimal` by @jkowalleck in https://github.com/madpah/serializable/pull/31 **Full Changelog**: https://github.com/madpah/serializable/compare/v0.14.0...v0.14.1 | Low | 10/8/2023 |
| v0.14.0 | ### Feature * Enhanced typehints and typing ([#27](https://github.com/madpah/serializable/issues/27)) ([`410372a`](https://github.com/madpah/serializable/commit/410372a0fa2713c5a36d790f08d2d4b52a6a187c)) ----- ## What's Changed * feat: enhanced typehints and typing by @jkowalleck in https://github.com/madpah/serializable/pull/27 **Full Changelog**: https://github.com/madpah/serializable/compare/v0.13.1...v0.14.0 | Low | 10/6/2023 |
| v0.13.1 | ### Fix * Protect default value for `serialization_types` from unintended downstream modifications ([#30](https://github.com/madpah/serializable/issues/30)) ([`0e814f5`](https://github.com/madpah/serializable/commit/0e814f5248176e02a7f96480e54320dde781f8b2)) ### Documentation * Add examples to docs ([#28](https://github.com/madpah/serializable/issues/28)) ([`4eddb24`](https://github.com/madpah/serializable/commit/4eddb242e51194694474748acdecd38b317b791e)) * Remove unnecessary type-igno | Low | 10/6/2023 |
| v0.13.0 | ### Feature * Format specific (de)serialize ([#25](https://github.com/madpah/serializable/issues/25)) ([`dc998df`](https://github.com/madpah/serializable/commit/dc998df37a2ba37fa43d10c8a1ce044a5b9f5b1e)) ----- ## What's Changed * feat: format specific (de)serialize by @jkowalleck in https://github.com/madpah/serializable/pull/25 **Full Changelog**: https://github.com/madpah/serializable/compare/v0.12.1...v0.13.0 | Low | 10/1/2023 |
| v0.12.1 | ### Fix * Xml defaultNamespace serialization and detection ([#20](https://github.com/madpah/serializable/issues/20)) ([`59eaa5f`](https://github.com/madpah/serializable/commit/59eaa5f28eb2969e9d497669ef0436eb87b7525d)) ### Documentation * Render only public API ([#19](https://github.com/madpah/serializable/issues/19)) ([`fcc5d8e`](https://github.com/madpah/serializable/commit/fcc5d8e6c49e8b8c199cb55f855d09e4259a075a)) * Set codeblock language and caption ([#15](https://github.com/madpa | Low | 10/1/2023 |
| v0.12.0 | ### Feature * Bump dev dependencies to latest (including `mypy` fixes) ([`06dcaa2`](https://github.com/madpah/serializable/commit/06dcaa28bfebb4505ddc67b287dc6f416822ffb6)) * Bump dev dependencies to latest (including `mypy` fixes) ([`6d70287`](https://github.com/madpah/serializable/commit/6d70287640c411d33823e9188b0baa81fba80c24)) ----- ## What's Changed * feat: bump dev dependencies to latest (including `mypy` fixes) by @madpah in https://github.com/madpah/serializable/pull/6 **F | Low | 3/7/2023 |
| v0.11.1 | ## What's Changed * fix: use `defusedxml` whenever we load XML to prevent XEE attacks by @madpah in https://github.com/madpah/serializable/pull/5 **Full Changelog**: https://github.com/madpah/serializable/compare/v0.11.0...v0.11.1 | Low | 3/3/2023 |
| v0.11.0 | ## What's Changed * feat: disabled handling to avoid class attributes that clash with `keywords` and `builtins` by @madpah in https://github.com/madpah/serializable/pull/4 **Full Changelog**: https://github.com/madpah/serializable/compare/v0.10.1...v0.11.0 | Low | 3/3/2023 |
| v0.10.1 | ### Fix * Handle empty XML elements during deserialization ([`f806f35`](https://github.com/madpah/serializable/commit/f806f3521f0afd8978f94f5ec355f47d9a538b91)) **Full Changelog**: https://github.com/madpah/serializable/compare/v0.10.0...v0.10.1 | Low | 3/2/2023 |
| v0.10.0 | ### Feature * Ability for custom `type_mapping` to take lower priority than `xml_array` ([`fc0bb22`](https://github.com/madpah/serializable/commit/fc0bb22f395498be42394af5f70addb9f63f0b3a)) * Handle `ForwardRef` types ([`a66e700`](https://github.com/madpah/serializable/commit/a66e700eeb5a80447522b8112ecdeff0345f0608)) **Full Changelog**: https://github.com/madpah/serializable/compare/v0.9.3...v0.10.0 | Low | 2/21/2023 |
| v0.9.3 | ### Fix * Deserializing JSON with custom JSON name was incorrect ([`7d4aefc`](https://github.com/madpah/serializable/commit/7d4aefc98dfe39ae614227601369e9fd25c12faa)) **Full Changelog**: https://github.com/madpah/serializable/compare/v0.9.2...v0.9.3 | Low | 1/27/2023 |
| v0.9.2 | ### Fix * Nested array of Enum values in `from_json()` failed ([`ea4d76a`](https://github.com/madpah/serializable/commit/ea4d76a64c8c97f7cb0b1[66](https://github.com/madpah/serializable/actions/runs/4023484509/jobs/6914409379#step:8:67)87f300c362dfe7623)) * Output better errors when deserializing JSON and we hit errors ([`1699c5b`](https://github.com/madpah/serializable/commit/1699c5b96bb6a8d4f034b29a6fe0521e3d650d53)) **Full Changelog**: https://github.com/madpah/serializable/compare/v0.9. | Low | 1/27/2023 |
| v0.9.1 | ### Fix * Nested array of Enum values in `from_xml()` failed ([`393a425`](https://github.com/madpah/serializable/commit/393a4256abb69228a9e6c2fc76b508e370a39d93)) **Full Changelog**: https://github.com/madpah/serializable/compare/v0.9.0...v0.9.1 | Low | 1/26/2023 |
| v0.9.0 | ### Feature * Bring library to BETA state ([`c6c36d9`](https://github.com/madpah/serializable/commit/c6c36d911ae401af477bcc98633f10a87140d0a4)) **Full Changelog**: https://github.com/madpah/serializable/compare/v0.8.2...v0.9.0 | Low | 1/24/2023 |
| v0.8.2 | ### Fix * Typing for `@serializable.view` was incorrect ([`756032b`](https://github.com/madpah/serializable/commit/756032b543a2fedac1bb61f57796eea438c0f9a7)) * Typing for `@serializable.serializable_enum` decorator was incorrect ([`84e7826`](https://github.com/madpah/serializable/commit/84e78262276833f507d4e8a1ce11d4a82733f395)) **Full Changelog**: https://github.com/madpah/serializable/compare/v0.8.1...v0.8.2 | Low | 1/23/2023 |
| v0.8.1 | ### Fix * Specific None value per View - support for XML was missing ([`5742861`](https://github.com/madpah/serializable/commit/5742861728d1b371bc0a819fed0b12e9da5829e1)) | Low | 1/23/2023 |
| v0.8.0 | ### Feature * Inclusion of property with None value now configurable by View * Per View None value can be customised **Full Changelog**: https://github.com/madpah/serializable/compare/v0.7.3...v0.8.0 | Low | 1/23/2023 |
| v0.7.2 | Fix: * Missing namespace for empty XML elements ([`f3659ab`](https://github.com/madpah/serializable/commit/f3659ab9ea651dcd65168aa22fa838d35ee189d5)) | Low | 9/22/2022 |
| v0.7.3 | ### Fix * None value for JSON is now `None` (`null`) ([`8b7f973`](https://github.com/madpah/serializable/commit/8b7f973cd96c861c4490c50553c880e88ebf33dc)) | Low | 9/22/2022 |
| v0.7.1 | ### Fix * Support forced inclusion of array properties by using `@serializable.include_none` ([`7ad0ecf`](https://github.com/madpah/serializable/commit/7ad0ecf08c5f56de4584f4f081bfc0f667d2f477)) * Support for deserializing to objects from a primitive value ([`12f9f97`](https://github.com/madpah/serializable/commit/12f9f9711a5fd924898a0afb50a24c8d360ab3ff)) | Low | 9/15/2022 |
| v0.7.0 | ### Feature * Support for including `None` values, restricted to certain Views as required ([`614068a`](https://github.com/madpah/serializable/commit/614068a4955f99d8fce5da341a1fd74a6772b775)) | Low | 9/14/2022 |
| v0.6.0 | ### Feature * Implement views for serialization to JSON and XML ([`db57ef1`](https://github.com/madpah/serializable/commit/db57ef13fa89cc47db074bd9be4b48232842df07)) ### Fix * Support for `Decimal` in JSON serialization ([`cc2c20f`](https://github.com/madpah/serializable/commit/cc2c20fe8bce46e4854cb0eecc6702459cd2f99a)) * Better serialization to JSON ([`e8b37f2`](https://github.com/madpah/serializable/commit/e8b37f2ee4246794c6c0e295bcdf32cd58d5e52d)) | Low | 9/14/2022 |
| v0.5.0 | ### Feature * Support for string formatting of values ([`99b8f3e`](https://github.com/madpah/serializable/commit/99b8f3e7ab84f087a87b330928fc598c96a0e682)) * Support string formatting for values ([`3fefe22`](https://github.com/madpah/serializable/commit/3fefe2294130b80f05e219bd655514a0956f7f93)) * Support for custom Enum implementations ([`c3622fc`](https://github.com/madpah/serializable/commit/c3622fcb0019de794b1cbd3ad6333b6044d8392a)) | Low | 9/12/2022 |
| v0.4.0 | ### Feature * Add support for defining XML element ordering with `@serializable.xml_sequence()` decorator ([`c1442ae`](https://github.com/madpah/serializable/commit/c1442aeb1776243922fbaa6b5174db5a54f71920)) ### Fix * Removed unused dependencies ([`448a3c9`](https://github.com/madpah/serializable/commit/448a3c9f0de897cf1ee6d7c46af377c2f389730d)) * Handle python builtins and keywords during `as_xml()` for element names ([`3bbfb1b`](https://github.com/madpah/serializable/commit/3bbfb1b4a7808f4ced | Low | 9/6/2022 |
| v0.3.9 | ### Fix * Support declaration of XML NS in `as_xml()` call ([`19b2b70`](https://github.com/madpah/serializable/commit/19b2b7048fdd7048d62f618987c13f2d3a457726)) | Low | 8/24/2022 |
| v0.3.8 | ### Fix * Deserialization of XML boolean values ([`799d477`](https://github.com/madpah/serializable/commit/799d4773d858fdf8597bef905302a373ca150db8)) | Low | 8/24/2022 |
| v0.3.7 | ### Fix * Fixed deferred parsing for Properties ([`833e29b`](https://github.com/madpah/serializable/commit/833e29b8391c85931b12c98f87a2faf3a68d388e)) | Low | 8/23/2022 |
| v0.3.6 | ### Fix * Support for cyclic dependencies ([`911626c`](https://github.com/madpah/serializable/commit/911626c88fb260049fdf2931f6ea1b0b05d7166a)) | Low | 8/23/2022 |
| v0.3.5 | ### Fix * Support for non-primitive types when XmlSerializationType == FLAT ([`7eff15b`](https://github.com/madpah/serializable/commit/7eff15bbb8d20760418071c005d65d2623b44eab)) | Low | 8/22/2022 |
| v0.3.4 | ### Fix * Support ENUM in XML Attributes ([`f2f0922`](https://github.com/madpah/serializable/commit/f2f0922f2d0280185f6fc7f96408d6647588c8d2)) | Low | 8/22/2022 |
| v0.3.3 | ### Fix * Handle Array types where the concrete type is quoted in its definition ([`b6db879`](https://github.com/madpah/serializable/commit/b6db879d72822ada74a41362594b009f09349da9)) | Low | 8/19/2022 |
| v0.3.2 | ### Fix * Work to support `sortedcontainers` as a return type for Properties ([`805a3f7`](https://github.com/madpah/serializable/commit/805a3f7a10e41f63b132ac0bb234497d5d39fe2b)) | Low | 8/19/2022 |
| v0.3.1 | ### Fix * Better support for Properties that have a Class type that is not a Serializable Class (e.g. UUID) ([`95d407b`](https://github.com/madpah/serializable/commit/95d407b4456d8f106cf54ceb650cbde1aab69457)) | Low | 8/19/2022 |
| v0.3.0 | ### Feature * Support ignoring elements/properties during deserialization ([`6319d1f`](https://github.com/madpah/serializable/commit/6319d1f9e632a941b1d79a63083c1ecb194105be)) | Low | 8/19/2022 |
| v0.2.3 | ### Fix * Update `helpers` to be properly typed ([`d924dc2`](https://github.com/madpah/serializable/commit/d924dc2d3b5f02c61ff6ac36fa10fa6adaac7022)) | Low | 8/19/2022 |
