{"id":20683303,"url":"https://github.com/hydrogen602/easy-serialize","last_synced_at":"2026-05-20T05:32:19.390Z","repository":{"id":57425251,"uuid":"362563835","full_name":"hydrogen602/easy-serialize","owner":"hydrogen602","description":"Easily convert custom python objects to string and back","archived":false,"fork":false,"pushed_at":"2021-10-10T21:46:55.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-17T18:03:48.727Z","etag":null,"topics":["json","python","serialization"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/easy-serialize/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hydrogen602.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-28T18:07:32.000Z","updated_at":"2021-10-20T01:17:58.000Z","dependencies_parsed_at":"2022-08-29T22:01:06.846Z","dependency_job_id":null,"html_url":"https://github.com/hydrogen602/easy-serialize","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hydrogen602%2Feasy-serialize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hydrogen602%2Feasy-serialize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hydrogen602%2Feasy-serialize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hydrogen602%2Feasy-serialize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hydrogen602","download_url":"https://codeload.github.com/hydrogen602/easy-serialize/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242933850,"owners_count":20208910,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","python","serialization"],"created_at":"2024-11-16T22:16:12.544Z","updated_at":"2026-05-20T05:32:19.247Z","avatar_url":"https://github.com/hydrogen602.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Easy-Serialize\n\nTurn custom python objects into strings and vice-versa.\n\n## Strengths\n\n- no extra code to write in most cases\n- supports json\n- supports nested objects\n- no dependencies outside of python's library (only pytest for developing)\n- ability to add methods to control serializing and deserializing\n- type hints and works with mypy\n\n## Drawbacks\n\n- objects like tuples are automatically turned into lists\n- only supports json right now\n- can't handle circular references\n- if an object has references in many places, it will be present in the json repeatedly and after deserializing will be separate objects\n- Because of this, it cannot handle linked lists or similar interconnected data structures well\n- stores `__dict__` of the object, so classes using `__slots__` will likely require overriding the `serialize` method and `deserialize` classmethod.\n\n## How to use\n\nExtend `Serializable`\n```\nclass A(Serializable):\n    ...\n```\n\nor use the `make_serializable` decorator\n```\n@make_serializable\nclass A:\n    ...\n```\n\nserialize using\n```\nserialize(object_to_serialize)\n```\n\nand deserialize using\n```\ndeserialize(stringified_object)\n```\n\n### Example\n\nRefer to [Simple Example](demo.py)\n\n### Custom serializing\n\nIn the case that the standard method doesn't cut it, it is\npossible to add custom serializing and deserializing methods to a class\n\n```\n@make_serializable\nclass A:\n    def __init__(self, x):\n        self.x = x\n\n    def serialize(self) -\u003e dict:\n        return {'x': self.x}\n    \n    @classmethod\n    def deserialize(cls, data: dict) -\u003e 'A':\n        return A(data['x'])\n```\n\n## Notes\n\n- `__init__` is by default not called for deserialized objects\n    - Because it needs to create the object and then copy over all the values of `__dict__`, it doesn't know the arguments used in `__init__`. Thus the object will be created with `__new__` which avoids calling `__init__`.\n\n## Future\n\nThings to possibly add:\n- other data formats like xml or the like\n- support for objects with circular references\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhydrogen602%2Feasy-serialize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhydrogen602%2Feasy-serialize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhydrogen602%2Feasy-serialize/lists"}