runtime-serialization


Nameruntime-serialization JSON
Version 0.0.0a1 PyPI version JSON
download
home_pageNone
SummaryProvides serialization to and from json, hjson, yaml and toml files.
upload_time2025-08-07 12:39:46
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords windows linux serialization
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            [![Test](https://github.com/apmadsen/runtime-serialization/actions/workflows/python-test.yml/badge.svg)](https://github.com/apmadsen/runtime-serialization/actions/workflows/python-test.yml)
[![Coverage](https://github.com/apmadsen/runtime-serialization/actions/workflows/python-test-coverage.yml/badge.svg)](https://github.com/apmadsen/runtime-serialization/actions/workflows/python-test-coverage.yml)
[![Stable Version](https://img.shields.io/pypi/v/runtime-serialization?label=stable&sort=semver&color=blue)](https://github.com/apmadsen/runtime-serialization/releases)
![Pre-release Version](https://img.shields.io/github/v/release/apmadsen/runtime-serialization?label=pre-release&include_prereleases&sort=semver&color=blue)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/runtime-serialization)
[![PyPI Downloads](https://static.pepy.tech/badge/runtime-serialization/week)](https://pepy.tech/projects/runtime-serialization)

# runtime-serialization

Provides serialization to and from json, hjson, yaml and toml files.

## Example

```python
from runtime.serialization.json import Serializer, serialize, deserialize
from runtime.serialization import serializable
from datetime import date

@serializable(namespace="tests.examples")
class Author:
    def __init__(self, name: str, birthday: date):
        self.__name = name
        self.__birthday = birthday

    @property
    def name(self) -> str:
        return self.__name

    @property
    def birthday(self) -> date:
        return self.__birthday

@serializable(namespace="tests.examples")
class Book:
    def __init__(self, title: str, author: Author):
        self.__title = title
        self.__author = author

    @property
    def title(self) -> str:
        return self.__title

    @property
    def author(self) -> Author:
        return self.__author

author = Author("Stephen King", date(1947, 9, 21))
book = Book("The Shining", author)
serializer = Serializer[Book]()
serialized = serializer.serialize(book) # -> {"author": {"birthday": "1947-09-21", "name": "Stephen King"}, "title": "The Shining"}
deserialized = serializer.deserialize(serialized)
assert deserialized.author.name == author.name
assert deserialized.title == book.title

# same result, different approach without the need for instantiating Serializer manually
serialized = serialize(book, Book)

# and without a base type, the type info is embedded
serialized_untyped = serialize(book) # -> {"author": {"birthday": "1947-09-21", "name": "Stephen King"}, "title": "The Shining", "~type": "tests.examples.Book"}
deserialized_untyped = deserialize(serialized_untyped)
assert deserialized_untyped.author.name == deserialized.author.name
assert deserialized_untyped.title == deserialized.title
```
## Full documentation

[Go to documentation](https://github.com/apmadsen/runtime-serialization/blob/main/docs/documentation.md)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "runtime-serialization",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "windows, linux, serialization",
    "author": null,
    "author_email": "Anders Madsen <anders.madsen@alphavue.com>",
    "download_url": "https://files.pythonhosted.org/packages/ae/34/3014d0ee91b33631de6aa721abf382685c7c64e9ad5472a628d4b84e9c39/runtime_serialization-0.0.0a1.tar.gz",
    "platform": null,
    "description": "[![Test](https://github.com/apmadsen/runtime-serialization/actions/workflows/python-test.yml/badge.svg)](https://github.com/apmadsen/runtime-serialization/actions/workflows/python-test.yml)\n[![Coverage](https://github.com/apmadsen/runtime-serialization/actions/workflows/python-test-coverage.yml/badge.svg)](https://github.com/apmadsen/runtime-serialization/actions/workflows/python-test-coverage.yml)\n[![Stable Version](https://img.shields.io/pypi/v/runtime-serialization?label=stable&sort=semver&color=blue)](https://github.com/apmadsen/runtime-serialization/releases)\n![Pre-release Version](https://img.shields.io/github/v/release/apmadsen/runtime-serialization?label=pre-release&include_prereleases&sort=semver&color=blue)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/runtime-serialization)\n[![PyPI Downloads](https://static.pepy.tech/badge/runtime-serialization/week)](https://pepy.tech/projects/runtime-serialization)\n\n# runtime-serialization\n\nProvides serialization to and from json, hjson, yaml and toml files.\n\n## Example\n\n```python\nfrom runtime.serialization.json import Serializer, serialize, deserialize\nfrom runtime.serialization import serializable\nfrom datetime import date\n\n@serializable(namespace=\"tests.examples\")\nclass Author:\n    def __init__(self, name: str, birthday: date):\n        self.__name = name\n        self.__birthday = birthday\n\n    @property\n    def name(self) -> str:\n        return self.__name\n\n    @property\n    def birthday(self) -> date:\n        return self.__birthday\n\n@serializable(namespace=\"tests.examples\")\nclass Book:\n    def __init__(self, title: str, author: Author):\n        self.__title = title\n        self.__author = author\n\n    @property\n    def title(self) -> str:\n        return self.__title\n\n    @property\n    def author(self) -> Author:\n        return self.__author\n\nauthor = Author(\"Stephen King\", date(1947, 9, 21))\nbook = Book(\"The Shining\", author)\nserializer = Serializer[Book]()\nserialized = serializer.serialize(book) # -> {\"author\": {\"birthday\": \"1947-09-21\", \"name\": \"Stephen King\"}, \"title\": \"The Shining\"}\ndeserialized = serializer.deserialize(serialized)\nassert deserialized.author.name == author.name\nassert deserialized.title == book.title\n\n# same result, different approach without the need for instantiating Serializer manually\nserialized = serialize(book, Book)\n\n# and without a base type, the type info is embedded\nserialized_untyped = serialize(book) # -> {\"author\": {\"birthday\": \"1947-09-21\", \"name\": \"Stephen King\"}, \"title\": \"The Shining\", \"~type\": \"tests.examples.Book\"}\ndeserialized_untyped = deserialize(serialized_untyped)\nassert deserialized_untyped.author.name == deserialized.author.name\nassert deserialized_untyped.title == deserialized.title\n```\n## Full documentation\n\n[Go to documentation](https://github.com/apmadsen/runtime-serialization/blob/main/docs/documentation.md)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Provides serialization to and from json, hjson, yaml and toml files.",
    "version": "0.0.0a1",
    "project_urls": {
        "repository": "https://github.com/apmadsen/runtime-serialization"
    },
    "split_keywords": [
        "windows",
        " linux",
        " serialization"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "67c375376b21b3c8731d1093c8facd5a961a6aad547308ca1197fa36628196c5",
                "md5": "10a43af7b099b42aa86e156273adc24c",
                "sha256": "36fa93fa3ff33de6288e090e06e1db7f39946f82bc9f8a6758f8673bf221bae7"
            },
            "downloads": -1,
            "filename": "runtime_serialization-0.0.0a1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "10a43af7b099b42aa86e156273adc24c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 42617,
            "upload_time": "2025-08-07T12:39:45",
            "upload_time_iso_8601": "2025-08-07T12:39:45.147437Z",
            "url": "https://files.pythonhosted.org/packages/67/c3/75376b21b3c8731d1093c8facd5a961a6aad547308ca1197fa36628196c5/runtime_serialization-0.0.0a1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ae343014d0ee91b33631de6aa721abf382685c7c64e9ad5472a628d4b84e9c39",
                "md5": "dcdc2791e2f136c104533bfcab3fc7a9",
                "sha256": "c46f5beaf4a0daaa475337cba2cb44d0b8f70252cf4b5bcbe7cf5763a016df9a"
            },
            "downloads": -1,
            "filename": "runtime_serialization-0.0.0a1.tar.gz",
            "has_sig": false,
            "md5_digest": "dcdc2791e2f136c104533bfcab3fc7a9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 34275,
            "upload_time": "2025-08-07T12:39:46",
            "upload_time_iso_8601": "2025-08-07T12:39:46.523328Z",
            "url": "https://files.pythonhosted.org/packages/ae/34/3014d0ee91b33631de6aa721abf382685c7c64e9ad5472a628d4b84e9c39/runtime_serialization-0.0.0a1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-07 12:39:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "apmadsen",
    "github_project": "runtime-serialization",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "runtime-serialization"
}
        
Elapsed time: 1.11335s